From 9d4bbbf80b8fd4493eb84e294dfdbddd7291cb2e Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Mon, 24 Jul 2023 18:02:30 +0800 Subject: [PATCH] fix --- .../internal/logic/gettagproductlistlogic.go | 28 +++++++++++++------ server/product/internal/types/types.go | 21 ++++++-------- server_api/product.api | 21 ++++++-------- 3 files changed, 35 insertions(+), 35 deletions(-) diff --git a/server/product/internal/logic/gettagproductlistlogic.go b/server/product/internal/logic/gettagproductlistlogic.go index 8a185eea..2ecc63b3 100644 --- a/server/product/internal/logic/gettagproductlistlogic.go +++ b/server/product/internal/logic/gettagproductlistlogic.go @@ -223,11 +223,9 @@ func (l *GetTagProductListLogic) dealWithTagMenuData(req dealWithTagMenuDataReq) TagProductList: nil, TypeName: *tagInfo.Title, TypeId: tagInfo.Id, - Level: int64(lenLevel), - LevelPrefix: *tagInfo.LevelPrefix, Icon: *tagInfo.Icon, Sort: *tagInfo.Sort, - Description: *tagInfo.Description, + LevelPrefix: *tagInfo.LevelPrefix, ChildTagList: make([]*types.TagItem, 0, 50), } //携带产品 @@ -243,8 +241,10 @@ func (l *GetTagProductListLogic) dealWithTagMenuData(req dealWithTagMenuDataReq) Size: req.Size, User: req.User, }) - //赋值 - tagTem.TagProductList = productListRsp + //tag中产品 + for _, tmpProduct := range productListRsp { + tagTem.TagProductList = append(tagTem.TagProductList, tmpProduct) + } } //加入分类 req.MapTagLevel[*tagInfo.LevelPrefix] = &tagTem @@ -255,6 +255,7 @@ func (l *GetTagProductListLogic) dealWithTagMenuData(req dealWithTagMenuDataReq) // 组织等级从属关系 func (l *GetTagProductListLogic) organizationLevelRelation(minLevel int, mapTagLevel map[string]*types.TagItem) []types.TagItem { mapTop := make(map[string]struct{}) + //设置归属关系 for prefix, tagItem := range mapTagLevel { prefixSlice := strings.Split(prefix, "/") //存储最高等级 @@ -275,6 +276,18 @@ func (l *GetTagProductListLogic) organizationLevelRelation(minLevel int, mapTagL }) mapTagLevel[parentPrefix] = parent } + //把子类的产品列表变成产品id列表并且把产品列表都放到最顶级父级中 + for _, v := range mapTagLevel { + if _, ok := mapTop[v.LevelPrefix]; ok { + continue + } + topPrefixSlic := strings.Split(v.LevelPrefix, "/")[:minLevel] + topPrefix := strings.Join(topPrefixSlic, "/") + for k, tmpProduct := range v.TagProductList { + v.TagProductList[k] = tmpProduct.(types.TagProduct).ProductId + mapTagLevel[topPrefix].TagProductList = append(mapTagLevel[topPrefix].TagProductList, tmpProduct) + } + } //最终值提取最高级别那一层出来 rspList := make([]types.TagItem, 0, len(mapTagLevel)) for prefix, _ := range mapTop { @@ -326,12 +339,10 @@ func (l *GetTagProductListLogic) getTagProducts(req getTagProductsReq) (productL ProductId: productInfo.Id, Sn: *productInfo.Sn, Title: *productInfo.Title, - Intro: *productInfo.Intro, - IsEnv: *productInfo.IsProtection, - IsMicro: *productInfo.IsMicrowave, SizeNum: uint32(sizeNum), MinPrice: minPrice, HaveOptionalFitting: haveOptionalFitting, + Recommended: *productInfo.IsRecommend > 0, } //千人千面处理 r := image.ThousandFaceImageFormatReq{ @@ -348,7 +359,6 @@ func (l *GetTagProductListLogic) getTagProducts(req getTagProductsReq) (productL } image.ThousandFaceImageFormat(&r) item.Cover = r.Cover - item.CoverImg = r.CoverImg item.CoverDefault = r.CoverDefault //加入分类产品切片 productListRsp = append(productListRsp, item) diff --git a/server/product/internal/types/types.go b/server/product/internal/types/types.go index 8109fec5..d995f714 100644 --- a/server/product/internal/types/types.go +++ b/server/product/internal/types/types.go @@ -258,15 +258,13 @@ type GetTagProductListRsp struct { } type TagItem struct { - TypeName string `json:"type_name"` - TypeId int64 `json:"type_id"` - Description string `json:"description"` - Level int64 `json:"level"` - LevelPrefix string `json:"level_prefix"` - Icon string `json:"icon"` - Sort int64 `json:"sort"` - TagProductList []TagProduct `json:"tag_product_list"` //分类下的产品 - ChildTagList []*TagItem `json:"child_tag_list"` + TypeName string `json:"type_name"` + TypeId int64 `json:"type_id"` + Icon string `json:"icon"` + Sort int64 `json:"sort"` + LevelPrefix string `json:"level_prefix"` + TagProductList []interface{} `json:"tag_product_list"` //分类下的产品 + ChildTagList []*TagItem `json:"child_tag_list"` } type TagProduct struct { @@ -274,14 +272,11 @@ type TagProduct struct { Sn string `json:"sn"` Title string `json:"title"` Cover string `json:"cover"` - Intro string `json:"intro"` - CoverImg string `json:"cover_img"` - IsEnv int64 `json:"is_env"` - IsMicro int64 `json:"is_micro"` SizeNum uint32 `json:"size_num"` MinPrice int64 `json:"min_price"` CoverDefault string `json:"cover_default"` HaveOptionalFitting bool `json:"have_optional_fitting"` + Recommended bool `json:"recommended"` } type GetRenderDesignReq struct { diff --git a/server_api/product.api b/server_api/product.api index a7160506..cef01f26 100644 --- a/server_api/product.api +++ b/server_api/product.api @@ -308,29 +308,24 @@ type GetTagProductListRsp { TagList []TagItem `json:"tag_list"` } type TagItem { - TypeName string `json:"type_name"` - TypeId int64 `json:"type_id"` - Description string `json:"description"` - Level int64 `json:"level"` - LevelPrefix string `json:"level_prefix"` - Icon string `json:"icon"` - Sort int64 `json:"sort"` - TagProductList []TagProduct `json:"tag_product_list"` //分类下的产品 - ChildTagList []*TagItem `json:"child_tag_list"` + TypeName string `json:"type_name"` + TypeId int64 `json:"type_id"` + Icon string `json:"icon"` + Sort int64 `json:"sort"` + LevelPrefix string `json:"level_prefix"` + TagProductList []interface{} `json:"tag_product_list"` //分类下的产品 + ChildTagList []*TagItem `json:"child_tag_list"` } type TagProduct { ProductId int64 `json:"product_id"` Sn string `json:"sn"` Title string `json:"title"` Cover string `json:"cover"` - Intro string `json:"intro"` - CoverImg string `json:"cover_img"` - IsEnv int64 `json:"is_env"` - IsMicro int64 `json:"is_micro"` SizeNum uint32 `json:"size_num"` MinPrice int64 `json:"min_price"` CoverDefault string `json:"cover_default"` HaveOptionalFitting bool `json:"have_optional_fitting"` + Recommended bool `json:"recommended"` } //获取云渲染设计方案信息 type GetRenderDesignReq {