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)

View File

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

View File

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