From 666147cfe65420652df87e50a57af95faae4d971 Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Thu, 17 Aug 2023 15:11:32 +0800 Subject: [PATCH] fix --- .../product/internal/logic/gettagproductlistlogic.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/server/product/internal/logic/gettagproductlistlogic.go b/server/product/internal/logic/gettagproductlistlogic.go index 0ebb5196..253c6e3c 100644 --- a/server/product/internal/logic/gettagproductlistlogic.go +++ b/server/product/internal/logic/gettagproductlistlogic.go @@ -209,9 +209,11 @@ func (l *GetTagProductListLogic) GetTagProductList(req *types.GetTagProductListR logx.Error(err) return resp.SetStatusAddMessage(basic.CodeServiceErr, "failed to deal with tag data") } + //组装等级从属关系 + rspTagList, TotalCategoryProduct := l.organizationLevelRelation(minLevel, mapTagLevel) return resp.SetStatusWithMessage(basic.CodeOK, "success", types.GetTagProductListRsp{ - TotalCategoryProduct: len(productList), - TagList: l.organizationLevelRelation(minLevel, mapTagLevel), //组装等级从属关系 + TotalCategoryProduct: TotalCategoryProduct, + TagList: rspTagList, }) } @@ -274,7 +276,7 @@ func (l *GetTagProductListLogic) dealWithTagMenuData(req dealWithTagMenuDataReq) } // 组织等级从属关系 -func (l *GetTagProductListLogic) organizationLevelRelation(minLevel int, mapTagLevel map[string]*types.TagItem) []types.TagItem { +func (l *GetTagProductListLogic) organizationLevelRelation(minLevel int, mapTagLevel map[string]*types.TagItem) (rspTagList []types.TagItem, productCount int) { mapTop := make(map[string]struct{}) //设置归属关系 for prefix, tagItem := range mapTagLevel { @@ -316,13 +318,14 @@ func (l *GetTagProductListLogic) organizationLevelRelation(minLevel int, mapTagL if len(mapTagLevel[prefix].TagProductList) == 0 { continue } + productCount += len(mapTagLevel[prefix].TagProductList) rspList = append(rspList, *mapTagLevel[prefix]) } //排序 sort.SliceStable(rspList, func(i, j int) bool { return rspList[i].Sort < rspList[j].Sort }) - return rspList + return rspList, productCount } // 获取对应tag的产品列表