refactor: 重构资产实体和DTO结构类型

将gjson.Json类型替换为具体的结构体和map类型,修正DAO层链式调用,启用SKU元数据校验逻辑
This commit is contained in:
2026-03-22 20:08:32 +08:00
parent 34a1ba79b6
commit 829dc07747
36 changed files with 932 additions and 793 deletions

View File

@@ -7,6 +7,8 @@ import (
"context"
"gitea.com/red-future/common/beans"
"gitea.com/red-future/common/http"
"github.com/gogf/gf/v2/frame/g"
"github.com/gogf/gf/v2/util/gconv"
)
@@ -39,17 +41,25 @@ func (s *enum) GetSpecsUnit(ctx context.Context, req *dto.GetSpecsUnitReq) (res
return
}
} else {
// 使用简化的 RPC 调用方式 - 直接传 map 参数
//dictData := &dto.GetDictRes{}
//if err = message.CallRPC(ctx, "dictService.GetDictWithDataByType", map[string]interface{}{"dictType": gconv.String(req.AssetType)}, dictData); err != nil {
// return
//}
//for _, v := range dictData.Values {
// res.Options = append(res.Options, dto.KeyValue{
// Key: v.DictValue,
// Value: v.DictLabel,
// })
//}
// 获取当前请求的 headers 并传递到下游
headers := make(map[string]string)
if r := g.RequestFromCtx(ctx); r != nil {
for k, v := range r.Request.Header {
if len(v) > 0 {
headers[k] = v[0]
}
}
}
dictData := &dto.GetDictRes{}
if err = http.Get(ctx, "admin-go/api/v1/system/dict/data/getDictData", headers, &dictData, "dictType", gconv.String(req.AssetType)); err != nil {
return
}
for _, v := range dictData.Values {
res.Options = append(res.Options, dto.KeyValue{
Key: v.DictValue,
Value: v.DictLabel,
})
}
}
return
}