This commit is contained in:
laodaming
2023-07-24 18:02:30 +08:00
parent 7e22f47a0d
commit 9d4bbbf80b
3 changed files with 35 additions and 35 deletions

View File

@@ -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)