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, TagProductList: nil,
TypeName: *tagInfo.Title, TypeName: *tagInfo.Title,
TypeId: tagInfo.Id, TypeId: tagInfo.Id,
Level: int64(lenLevel),
LevelPrefix: *tagInfo.LevelPrefix,
Icon: *tagInfo.Icon, Icon: *tagInfo.Icon,
Sort: *tagInfo.Sort, Sort: *tagInfo.Sort,
Description: *tagInfo.Description, LevelPrefix: *tagInfo.LevelPrefix,
ChildTagList: make([]*types.TagItem, 0, 50), ChildTagList: make([]*types.TagItem, 0, 50),
} }
//携带产品 //携带产品
@ -243,8 +241,10 @@ func (l *GetTagProductListLogic) dealWithTagMenuData(req dealWithTagMenuDataReq)
Size: req.Size, Size: req.Size,
User: req.User, User: req.User,
}) })
//赋值 //tag中产品
tagTem.TagProductList = productListRsp for _, tmpProduct := range productListRsp {
tagTem.TagProductList = append(tagTem.TagProductList, tmpProduct)
}
} }
//加入分类 //加入分类
req.MapTagLevel[*tagInfo.LevelPrefix] = &tagTem 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 { func (l *GetTagProductListLogic) organizationLevelRelation(minLevel int, mapTagLevel map[string]*types.TagItem) []types.TagItem {
mapTop := make(map[string]struct{}) mapTop := make(map[string]struct{})
//设置归属关系
for prefix, tagItem := range mapTagLevel { for prefix, tagItem := range mapTagLevel {
prefixSlice := strings.Split(prefix, "/") prefixSlice := strings.Split(prefix, "/")
//存储最高等级 //存储最高等级
@ -275,6 +276,18 @@ func (l *GetTagProductListLogic) organizationLevelRelation(minLevel int, mapTagL
}) })
mapTagLevel[parentPrefix] = parent 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)) rspList := make([]types.TagItem, 0, len(mapTagLevel))
for prefix, _ := range mapTop { for prefix, _ := range mapTop {
@ -326,12 +339,10 @@ func (l *GetTagProductListLogic) getTagProducts(req getTagProductsReq) (productL
ProductId: productInfo.Id, ProductId: productInfo.Id,
Sn: *productInfo.Sn, Sn: *productInfo.Sn,
Title: *productInfo.Title, Title: *productInfo.Title,
Intro: *productInfo.Intro,
IsEnv: *productInfo.IsProtection,
IsMicro: *productInfo.IsMicrowave,
SizeNum: uint32(sizeNum), SizeNum: uint32(sizeNum),
MinPrice: minPrice, MinPrice: minPrice,
HaveOptionalFitting: haveOptionalFitting, HaveOptionalFitting: haveOptionalFitting,
Recommended: *productInfo.IsRecommend > 0,
} }
//千人千面处理 //千人千面处理
r := image.ThousandFaceImageFormatReq{ r := image.ThousandFaceImageFormatReq{
@ -348,7 +359,6 @@ func (l *GetTagProductListLogic) getTagProducts(req getTagProductsReq) (productL
} }
image.ThousandFaceImageFormat(&r) image.ThousandFaceImageFormat(&r)
item.Cover = r.Cover item.Cover = r.Cover
item.CoverImg = r.CoverImg
item.CoverDefault = r.CoverDefault item.CoverDefault = r.CoverDefault
//加入分类产品切片 //加入分类产品切片
productListRsp = append(productListRsp, item) productListRsp = append(productListRsp, item)

View File

@ -260,12 +260,10 @@ type GetTagProductListRsp struct {
type TagItem struct { type TagItem struct {
TypeName string `json:"type_name"` TypeName string `json:"type_name"`
TypeId int64 `json:"type_id"` TypeId int64 `json:"type_id"`
Description string `json:"description"`
Level int64 `json:"level"`
LevelPrefix string `json:"level_prefix"`
Icon string `json:"icon"` Icon string `json:"icon"`
Sort int64 `json:"sort"` Sort int64 `json:"sort"`
TagProductList []TagProduct `json:"tag_product_list"` //分类下的产品 LevelPrefix string `json:"level_prefix"`
TagProductList []interface{} `json:"tag_product_list"` //分类下的产品
ChildTagList []*TagItem `json:"child_tag_list"` ChildTagList []*TagItem `json:"child_tag_list"`
} }
@ -274,14 +272,11 @@ type TagProduct struct {
Sn string `json:"sn"` Sn string `json:"sn"`
Title string `json:"title"` Title string `json:"title"`
Cover string `json:"cover"` 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"` SizeNum uint32 `json:"size_num"`
MinPrice int64 `json:"min_price"` MinPrice int64 `json:"min_price"`
CoverDefault string `json:"cover_default"` CoverDefault string `json:"cover_default"`
HaveOptionalFitting bool `json:"have_optional_fitting"` HaveOptionalFitting bool `json:"have_optional_fitting"`
Recommended bool `json:"recommended"`
} }
type GetRenderDesignReq struct { type GetRenderDesignReq struct {

View File

@ -310,12 +310,10 @@ type GetTagProductListRsp {
type TagItem { type TagItem {
TypeName string `json:"type_name"` TypeName string `json:"type_name"`
TypeId int64 `json:"type_id"` TypeId int64 `json:"type_id"`
Description string `json:"description"`
Level int64 `json:"level"`
LevelPrefix string `json:"level_prefix"`
Icon string `json:"icon"` Icon string `json:"icon"`
Sort int64 `json:"sort"` Sort int64 `json:"sort"`
TagProductList []TagProduct `json:"tag_product_list"` //分类下的产品 LevelPrefix string `json:"level_prefix"`
TagProductList []interface{} `json:"tag_product_list"` //分类下的产品
ChildTagList []*TagItem `json:"child_tag_list"` ChildTagList []*TagItem `json:"child_tag_list"`
} }
type TagProduct { type TagProduct {
@ -323,14 +321,11 @@ type TagProduct {
Sn string `json:"sn"` Sn string `json:"sn"`
Title string `json:"title"` Title string `json:"title"`
Cover string `json:"cover"` 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"` SizeNum uint32 `json:"size_num"`
MinPrice int64 `json:"min_price"` MinPrice int64 `json:"min_price"`
CoverDefault string `json:"cover_default"` CoverDefault string `json:"cover_default"`
HaveOptionalFitting bool `json:"have_optional_fitting"` HaveOptionalFitting bool `json:"have_optional_fitting"`
Recommended bool `json:"recommended"`
} }
//获取云渲染设计方案信息 //获取云渲染设计方案信息
type GetRenderDesignReq { type GetRenderDesignReq {