This commit is contained in:
laodaming 2023-09-19 10:36:33 +08:00
parent 34befce2f3
commit 19958a80de
3 changed files with 9 additions and 11 deletions

View File

@ -125,16 +125,13 @@ func (l *GetProductTemplateTagsLogic) GetProductTemplateTags(req *types.GetProdu
list := make([]types.GetProductTemplateTagsRsp, 0, len(productTemplateTags))
for _, templateInfo := range productTemplateTags {
colors := make([]types.ColorsItem, 0, 10)
for index, v := range mapTemplateTag[*templateInfo.TemplateTag] {
selected := false
SelectedIndex := 0
for _, colorsSet := range mapTemplateTag[*templateInfo.TemplateTag] {
if selectIndex, ok := mapSelectColor[*templateInfo.TemplateTag]; ok {
if index == selectIndex {
selected = true
}
SelectedIndex = selectIndex
}
colors = append(colors, types.ColorsItem{
Color: v,
Selected: selected,
Color: colorsSet,
})
}
list = append(list, types.GetProductTemplateTagsRsp{
@ -143,6 +140,7 @@ func (l *GetProductTemplateTagsLogic) GetProductTemplateTags(req *types.GetProdu
Cover: *templateInfo.Cover,
CoverMetadata: mapResourceMetadata[*templateInfo.Cover],
Colors: colors,
SelectedIndex: SelectedIndex,
})
}
return resp.SetStatusWithMessage(basic.CodeOK, "success", list)

View File

@ -15,11 +15,11 @@ type GetProductTemplateTagsRsp struct {
Cover string `json:"cover"`
CoverMetadata interface{} `json:"cover_metadata"`
Colors []ColorsItem `json:"colors"`
SelectedIndex int `json:"selected_index"`
}
type ColorsItem struct {
Color []string `json:"color"`
Selected bool `json:"selected"`
Color []string `json:"color"`
}
type Request struct {

View File

@ -25,8 +25,8 @@ type GetProductTemplateTagsRsp {
Cover string `json:"cover"`
CoverMetadata interface{} `json:"cover_metadata"`
Colors []ColorsItem `json:"colors"`
SelectedIndex int `json:"selected_index"`
}
type ColorsItem {
Color []string `json:"color"`
Selected bool `json:"selected"`
Color []string `json:"color"`
}