fix
This commit is contained in:
parent
990c7d3359
commit
49cc50ff4e
|
@ -54,33 +54,31 @@ func (l *GetProductTemplateTagsLogic) GetProductTemplateTags(req *types.GetProdu
|
|||
logx.Error(err)
|
||||
return
|
||||
}
|
||||
var colors interface{}
|
||||
var colors map[string][]types.ColorsItem
|
||||
if logoInfo.Metadata == nil || *logoInfo.Metadata == "" {
|
||||
// 返回固定模板A1a
|
||||
productTemplateTags, err = l.svcCtx.AllModels.FsProductTemplateTags.GetListByTagNames(l.ctx, []string{"A1"}, req.Limit, 1, "`id` DESC")
|
||||
if err != nil {
|
||||
logx.Error(err)
|
||||
return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get template tags")
|
||||
}
|
||||
} else {
|
||||
//解析元数据
|
||||
var metaData map[string]interface{}
|
||||
if err = json.Unmarshal([]byte(*logoInfo.Metadata), &metaData); err != nil {
|
||||
logx.Error(err)
|
||||
return resp.SetStatusWithMessage(basic.CodeJsonErr, "failed to parse user metadata")
|
||||
}
|
||||
colors = metaData["colors"]
|
||||
var templateTagNameList []string
|
||||
b, _ := json.Marshal(metaData["template_tagid"])
|
||||
if err = json.Unmarshal(b, &templateTagNameList); err != nil {
|
||||
logx.Error(err)
|
||||
return resp.SetStatusWithMessage(basic.CodeJsonErr, "invalid format of metadata`s template_tagid")
|
||||
}
|
||||
productTemplateTags, err = l.svcCtx.AllModels.FsProductTemplateTags.GetListByTagNames(l.ctx, templateTagNameList, req.Limit, 1, "id DESC")
|
||||
if err != nil {
|
||||
logx.Error(err)
|
||||
return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get template tags")
|
||||
}
|
||||
return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "logo info`s metadata is not set")
|
||||
}
|
||||
//解析元数据
|
||||
var metaData map[string]interface{}
|
||||
if err = json.Unmarshal([]byte(*logoInfo.Metadata), &metaData); err != nil {
|
||||
logx.Error(err)
|
||||
return resp.SetStatusWithMessage(basic.CodeJsonErr, "failed to parse user metadata")
|
||||
}
|
||||
b, _ := json.Marshal(metaData["colors"])
|
||||
if err = json.Unmarshal(b, &colors); err != nil {
|
||||
logx.Error(err)
|
||||
return resp.SetStatusWithMessage(basic.CodeJsonErr, "invalid format of metadata`s colors")
|
||||
}
|
||||
var templateTagNameList []string
|
||||
b, _ = json.Marshal(metaData["template_tagid"])
|
||||
if err = json.Unmarshal(b, &templateTagNameList); err != nil {
|
||||
logx.Error(err)
|
||||
return resp.SetStatusWithMessage(basic.CodeJsonErr, "invalid format of metadata`s template_tagid")
|
||||
}
|
||||
productTemplateTags, err = l.svcCtx.AllModels.FsProductTemplateTags.GetListByTagNames(l.ctx, templateTagNameList, req.Limit, 1, "id DESC")
|
||||
if err != nil {
|
||||
logx.Error(err)
|
||||
return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get template tags")
|
||||
}
|
||||
//资源id集合
|
||||
resourceIds := make([]string, 0, 5)
|
||||
|
|
|
@ -10,11 +10,20 @@ type GetProductTemplateTagsReq struct {
|
|||
}
|
||||
|
||||
type GetProductTemplateTagsRsp struct {
|
||||
Id int64 `json:"id"`
|
||||
TemplateTag string `json:"template_tag"`
|
||||
Cover string `json:"cover"`
|
||||
CoverMetadata interface{} `json:"cover_metadata"`
|
||||
Colors interface{} `json:"colors"`
|
||||
Id int64 `json:"id"`
|
||||
TemplateTag string `json:"template_tag"`
|
||||
Cover string `json:"cover"`
|
||||
CoverMetadata interface{} `json:"cover_metadata"`
|
||||
Colors map[string][]ColorsItem `json:"colors"`
|
||||
}
|
||||
|
||||
type ColorsItem struct {
|
||||
Color []ColorItem `json:"color"`
|
||||
}
|
||||
|
||||
type ColorItem struct {
|
||||
Value string `json:"value"`
|
||||
Selected bool `json:"selected"`
|
||||
}
|
||||
|
||||
type Request struct {
|
||||
|
|
|
@ -20,9 +20,16 @@ type GetProductTemplateTagsReq {
|
|||
Limit int `form:"limit"`
|
||||
}
|
||||
type GetProductTemplateTagsRsp {
|
||||
Id int64 `json:"id"`
|
||||
TemplateTag string `json:"template_tag"`
|
||||
Cover string `json:"cover"`
|
||||
CoverMetadata interface{} `json:"cover_metadata"`
|
||||
Colors interface{} `json:"colors"`
|
||||
Id int64 `json:"id"`
|
||||
TemplateTag string `json:"template_tag"`
|
||||
Cover string `json:"cover"`
|
||||
CoverMetadata interface{} `json:"cover_metadata"`
|
||||
Colors map[string][]ColorsItem `json:"colors"`
|
||||
}
|
||||
type ColorsItem {
|
||||
Color []ColorItem `json:"color"`
|
||||
}
|
||||
type ColorItem {
|
||||
Value string `json:"value"`
|
||||
Selected bool `json:"selected"`
|
||||
}
|
Loading…
Reference in New Issue
Block a user