From 56a8b32d90ac4ab5718c0fa86407ea80162098fe Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Fri, 14 Jul 2023 14:07:23 +0800 Subject: [PATCH] fix --- .../internal/logic/gettagproductlistlogic.go | 13 ++++++++----- server/product/internal/types/types.go | 3 ++- server_api/product.api | 3 ++- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/server/product/internal/logic/gettagproductlistlogic.go b/server/product/internal/logic/gettagproductlistlogic.go index 9844130f..e39bfb7f 100644 --- a/server/product/internal/logic/gettagproductlistlogic.go +++ b/server/product/internal/logic/gettagproductlistlogic.go @@ -184,18 +184,21 @@ func (l *GetTagProductListLogic) GetTagProductList(req *types.GetTagProductListR } } //最终值提取最高级别那一层出来 - menus := make([]types.TagItem, 0, len(mapTagLevel)) + tagListRsp := make([]types.TagItem, 0, len(mapTagLevel)) for _, v := range mapTagLevel { if v.Level != minLevel { continue } - menus = append(menus, *v) + tagListRsp = append(tagListRsp, *v) } //排序 - sort.Slice(menus, func(i, j int) bool { - return menus[i].Sort < menus[j].Sort + sort.Slice(tagListRsp, func(i, j int) bool { + return tagListRsp[i].Sort < tagListRsp[j].Sort + }) + return resp.SetStatusWithMessage(basic.CodeOK, "success", types.GetTagProductListRsp{ + TotalCategory: len(mapTagLevel), + TagList: tagListRsp, }) - return resp.SetStatusWithMessage(basic.CodeOK, "success", menus) } // 获取对应tag的产品列表 diff --git a/server/product/internal/types/types.go b/server/product/internal/types/types.go index 573f6a5d..f97f220d 100644 --- a/server/product/internal/types/types.go +++ b/server/product/internal/types/types.go @@ -250,7 +250,8 @@ type GetTagProductListReq struct { } type GetTagProductListRsp struct { - TagList []TagItem `json:"tag_list"` + TotalCategory int `json:"totalCategory"` + TagList []TagItem `json:"tag_list"` } type TagItem struct { diff --git a/server_api/product.api b/server_api/product.api index fa469e46..2c1ddf71 100644 --- a/server_api/product.api +++ b/server_api/product.api @@ -266,7 +266,8 @@ type GetTagProductListReq { Size uint32 `form:"size,optional"` //尺寸 } type GetTagProductListRsp { - TagList []TagItem `json:"tag_list"` + TotalCategory int `json:"totalCategory"` + TagList []TagItem `json:"tag_list"` } type TagItem { TypeName string `json:"type_name"`