sync: 同步 v1.0.4 开源代码并脱敏
This commit is contained in:
@@ -22,11 +22,10 @@ import (
|
||||
// setupImeiBatchDB 建一张最小可用的卡表并灌入覆盖各分支的样本数据。
|
||||
//
|
||||
// 样本设计(对齐 §7 测试场景):
|
||||
//
|
||||
// CARD-A 有 imei → 正常命中
|
||||
// CARD-B imei 为空 → 卡存在但上游未上报值
|
||||
// CARD-C 有 imei → 正常命中(入库带的值)
|
||||
// CARD-D 属于另一个部门 → 数据权限过滤后视为 notFound
|
||||
// CARD-A 有 imei → 正常命中
|
||||
// CARD-B imei 为空 → 卡存在但上游未上报值
|
||||
// CARD-C 有 imei → 正常命中(入库带的值)
|
||||
// CARD-D 属于另一个部门 → 数据权限过滤后视为 notFound
|
||||
func setupImeiBatchDB(t *testing.T, ctx context.Context) {
|
||||
t.Helper()
|
||||
if err := gdb.SetConfig(gdb.Config{"default": gdb.ConfigGroup{{Type: "sqlite", Link: "sqlite::@file(:memory:)", MaxOpenConnCount: 1}}}); err != nil {
|
||||
|
||||
@@ -286,7 +286,7 @@ func (s *sQueryToken) GenerateToken(ctx context.Context, customer *model.CustomC
|
||||
ets := g.Cfg().MustGet(ctx, "jwt.expiresTime", "3650d").String()
|
||||
bts := g.Cfg().MustGet(ctx, "jwt.bufferTime", "1d").String()
|
||||
iss := g.Cfg().MustGet(ctx, "jwt.issuer", "JieIOTAPI").String()
|
||||
sk := g.Cfg().MustGet(ctx, "jwt.signingKey", "${JWT_SIGNING_KEY}").String()
|
||||
sk := g.Cfg().MustGet(ctx, "jwt.signingKey", "49c54195e73304e74a8429b178965865").String()
|
||||
et, _ := utils.ParseDuration(ets)
|
||||
bt, _ := utils.ParseDuration(bts)
|
||||
g.Log().Infof(ctx, "GenerateToken: customer:%+v, et:%s, bt:%s, iss:%s", customer, et, bt, iss)
|
||||
@@ -336,7 +336,7 @@ func (s *sQueryToken) GenerateToken(ctx context.Context, customer *model.CustomC
|
||||
|
||||
// GenerateShortToken 生成短令牌
|
||||
func (s *sQueryToken) GenerateShortToken(ctx context.Context, tokenUuid string) (token string, err error) {
|
||||
sk := g.Cfg().MustGet(ctx, "jwt.signingKey", "${JWT_SIGNING_KEY}").String()
|
||||
sk := g.Cfg().MustGet(ctx, "jwt.signingKey", "49c54195e73304e74a8429b178965865").String()
|
||||
shortToken := jwt.NewWithClaims(jwt.SigningMethodHS256, &model.ApiTokenClaims{
|
||||
UUID: tokenUuid,
|
||||
})
|
||||
@@ -346,7 +346,7 @@ func (s *sQueryToken) GenerateShortToken(ctx context.Context, tokenUuid string)
|
||||
|
||||
// 解析Token
|
||||
func (s *sQueryToken) ParseToken(ctx context.Context, token string) (claims *model.CustomClaimsApi, err error) {
|
||||
sk := g.Cfg().MustGet(ctx, "jwt.signingKey", "${JWT_SIGNING_KEY}").String()
|
||||
sk := g.Cfg().MustGet(ctx, "jwt.signingKey", "49c54195e73304e74a8429b178965865").String()
|
||||
t, err := jwt.ParseWithClaims(token, &model.ApiTokenClaims{}, func(token *jwt.Token) (interface{}, error) {
|
||||
return []byte(sk), nil
|
||||
})
|
||||
@@ -386,7 +386,7 @@ func (s *sQueryToken) ParseToken(ctx context.Context, token string) (claims *mod
|
||||
|
||||
// 删除Token
|
||||
func (s *sQueryToken) DeleteToken(ctx context.Context, token string) (err error) {
|
||||
sk := g.Cfg().MustGet(ctx, "jwt.signingKey", "${JWT_SIGNING_KEY}").String()
|
||||
sk := g.Cfg().MustGet(ctx, "jwt.signingKey", "49c54195e73304e74a8429b178965865").String()
|
||||
t, err := jwt.ParseWithClaims(token, &model.ApiTokenClaims{}, func(token *jwt.Token) (interface{}, error) {
|
||||
return []byte(sk), nil
|
||||
})
|
||||
|
||||
@@ -4,11 +4,11 @@ import (
|
||||
"context"
|
||||
"strings"
|
||||
|
||||
"github.com/gogf/gf/v2/errors/gerror"
|
||||
"git.5iot.com/iotlcm-public/iotlcm-openapi/internal/dao"
|
||||
"git.5iot.com/iotlcm-public/iotlcm-openapi/internal/model"
|
||||
"git.5iot.com/iotlcm-public/iotlcm-openapi/internal/model/entity"
|
||||
"git.5iot.com/iotlcm-public/iotlcm-openapi/internal/service"
|
||||
"github.com/gogf/gf/v2/errors/gerror"
|
||||
)
|
||||
|
||||
const queryTrafficCutoffConfigMaxCards = 1000
|
||||
|
||||
Reference in New Issue
Block a user