Merge branch 'develop' of gitee.com:fusenpack/fusenapi into develop
This commit is contained in:
commit
43c667e6b0
|
@ -73,12 +73,20 @@ func (l *GetProductTemplateTagsLogic) GetProductTemplateTags(req *types.GetProdu
|
|||
logx.Error(err)
|
||||
return resp.SetStatusWithMessage(basic.CodeJsonErr, "failed to parse user metadata")
|
||||
}
|
||||
var mapMaterialTemplateTag map[string][][]string
|
||||
//解析模板标签颜色
|
||||
var mapMaterialTemplateTagColors map[string][][]string
|
||||
b, _ := json.Marshal(metaData["template_tag"])
|
||||
if err = json.Unmarshal(b, &mapMaterialTemplateTag); err != nil {
|
||||
if err = json.Unmarshal(b, &mapMaterialTemplateTagColors); err != nil {
|
||||
logx.Error(err)
|
||||
return resp.SetStatusWithMessage(basic.CodeJsonErr, "invalid format of metadata`s template_tag")
|
||||
}
|
||||
//解析单纯的模板标签用于排序
|
||||
var simpleTemplateTags []string
|
||||
b, _ = json.Marshal(metaData["template_tag_id"])
|
||||
if err = json.Unmarshal(b, &simpleTemplateTags); err != nil {
|
||||
logx.Error(err)
|
||||
return resp.SetStatusWithMessage(basic.CodeJsonErr, "invalid format of metadata`s template_tag_id")
|
||||
}
|
||||
//从用户元数据获取选中的颜色数据
|
||||
mapSelectColor := make(map[string]int) //key是模板标签val是选中的索引
|
||||
if logoInfo.UserInfoMetadata != nil && *logoInfo.UserInfoMetadata != "" {
|
||||
|
@ -90,12 +98,12 @@ func (l *GetProductTemplateTagsLogic) GetProductTemplateTags(req *types.GetProdu
|
|||
}
|
||||
//设置选中
|
||||
key := logoSelectInfo.LogoSelected.TemplateTagSelected.TemplateTag
|
||||
if _, ok := mapMaterialTemplateTag[key]; ok {
|
||||
if _, ok := mapMaterialTemplateTagColors[key]; ok {
|
||||
mapSelectColor[key] = logoSelectInfo.LogoSelected.TemplateTagSelected.SelectedIndex
|
||||
}
|
||||
}
|
||||
var templateTagNameList []string
|
||||
for templateTag, _ := range mapMaterialTemplateTag {
|
||||
for templateTag, _ := range mapMaterialTemplateTagColors {
|
||||
templateTagNameList = append(templateTagNameList, templateTag)
|
||||
}
|
||||
productTemplateTags, err = l.svcCtx.AllModels.FsProductTemplateTags.GetListByTagNames(l.ctx, templateTagNameList, req.Limit, 1, "id DESC")
|
||||
|
@ -122,15 +130,23 @@ func (l *GetProductTemplateTagsLogic) GetProductTemplateTags(req *types.GetProdu
|
|||
}
|
||||
mapResourceMetadata[*v.ResourceUrl] = metadata
|
||||
}
|
||||
//排序
|
||||
for index, templateTagStr := range simpleTemplateTags {
|
||||
for k, v := range productTemplateTags {
|
||||
if templateTagStr == *v.TemplateTag {
|
||||
productTemplateTags[k], productTemplateTags[index] = productTemplateTags[index], productTemplateTags[k]
|
||||
}
|
||||
}
|
||||
}
|
||||
list := make([]types.GetProductTemplateTagsRsp, 0, len(productTemplateTags))
|
||||
for _, templateInfo := range productTemplateTags {
|
||||
for _, templateTagInfo := range productTemplateTags {
|
||||
colors := make([][]string, 0, 10)
|
||||
SelectedColorIndex := 0
|
||||
isDefaultTemplateTag := false
|
||||
//查看用户素材中标签对应的颜色
|
||||
if colorsSet, ok := mapMaterialTemplateTag[*templateInfo.TemplateTag]; ok {
|
||||
if colorsSet, ok := mapMaterialTemplateTagColors[*templateTagInfo.TemplateTag]; ok {
|
||||
//是不是选中的标签
|
||||
if selectIndex, ok := mapSelectColor[*templateInfo.TemplateTag]; ok {
|
||||
if selectIndex, ok := mapSelectColor[*templateTagInfo.TemplateTag]; ok {
|
||||
isDefaultTemplateTag = true
|
||||
//标签中选中的索引
|
||||
SelectedColorIndex = selectIndex
|
||||
|
@ -139,19 +155,19 @@ func (l *GetProductTemplateTagsLogic) GetProductTemplateTags(req *types.GetProdu
|
|||
colors = colorsSet
|
||||
}
|
||||
var templateTagGroups []interface{}
|
||||
if templateInfo.Groups != nil && *templateInfo.Groups != "" {
|
||||
if err = json.Unmarshal([]byte(*templateInfo.Groups), &templateTagGroups); err != nil {
|
||||
if templateTagInfo.Groups != nil && *templateTagInfo.Groups != "" {
|
||||
if err = json.Unmarshal([]byte(*templateTagInfo.Groups), &templateTagGroups); err != nil {
|
||||
logx.Error(err)
|
||||
return resp.SetStatusWithMessage(basic.CodeJsonErr, "failed to parse groups")
|
||||
}
|
||||
}
|
||||
list = append(list, types.GetProductTemplateTagsRsp{
|
||||
Id: templateInfo.Id,
|
||||
TemplateTag: *templateInfo.TemplateTag,
|
||||
Id: templateTagInfo.Id,
|
||||
TemplateTag: *templateTagInfo.TemplateTag,
|
||||
IsDefaultTemplateTag: isDefaultTemplateTag,
|
||||
TemplateTagGroups: templateTagGroups,
|
||||
Cover: *templateInfo.Cover,
|
||||
CoverMetadata: mapResourceMetadata[*templateInfo.Cover],
|
||||
Cover: *templateTagInfo.Cover,
|
||||
CoverMetadata: mapResourceMetadata[*templateTagInfo.Cover],
|
||||
Colors: colors,
|
||||
SelectedColorIndex: SelectedColorIndex,
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue
Block a user