From 19958a80de9ce37b6daed0dc251eb4cc32231d43 Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Tue, 19 Sep 2023 10:36:33 +0800 Subject: [PATCH] fix --- .../internal/logic/getproducttemplatetagslogic.go | 12 +++++------- server/product-template-tag/internal/types/types.go | 4 ++-- server_api/product-template-tag.api | 4 ++-- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/server/product-template-tag/internal/logic/getproducttemplatetagslogic.go b/server/product-template-tag/internal/logic/getproducttemplatetagslogic.go index c76f2048..351fce2b 100644 --- a/server/product-template-tag/internal/logic/getproducttemplatetagslogic.go +++ b/server/product-template-tag/internal/logic/getproducttemplatetagslogic.go @@ -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) diff --git a/server/product-template-tag/internal/types/types.go b/server/product-template-tag/internal/types/types.go index 574a34c6..7474e8da 100644 --- a/server/product-template-tag/internal/types/types.go +++ b/server/product-template-tag/internal/types/types.go @@ -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 { diff --git a/server_api/product-template-tag.api b/server_api/product-template-tag.api index 30329047..6c88a573 100644 --- a/server_api/product-template-tag.api +++ b/server_api/product-template-tag.api @@ -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"` } \ No newline at end of file