fix
This commit is contained in:
parent
28076f2441
commit
edd19afcf3
@ -129,10 +129,9 @@ func (l *GetTagProductListLogic) GetTagProductList(req *types.GetTagProductListR
|
|||||||
return resp.SetStatusAddMessage(basic.CodeServiceErr, "failed to deal with tag data")
|
return resp.SetStatusAddMessage(basic.CodeServiceErr, "failed to deal with tag data")
|
||||||
}
|
}
|
||||||
//组装等级从属关系
|
//组装等级从属关系
|
||||||
rspTagList, mapTagRsp, TotalCategoryProduct := l.organizationLevelRelation(minLevel, mapTagLevel, productList, mapTagProduct)
|
mapTagRsp, TotalCategoryProduct := l.organizationLevelRelation(minLevel, mapTagLevel, productList, mapTagProduct)
|
||||||
return resp.SetStatusWithMessage(basic.CodeOK, "success", types.GetTagProductListRsp{
|
return resp.SetStatusWithMessage(basic.CodeOK, "success", types.GetTagProductListRsp{
|
||||||
TotalCategoryProduct: TotalCategoryProduct,
|
TotalCategoryProduct: TotalCategoryProduct,
|
||||||
TagList: rspTagList,
|
|
||||||
TagMap: mapTagRsp,
|
TagMap: mapTagRsp,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -321,7 +320,7 @@ func (l *GetTagProductListLogic) dealWithTagMenuData(req dealWithTagMenuDataReq)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 组织等级从属关系
|
// 组织等级从属关系
|
||||||
func (l *GetTagProductListLogic) organizationLevelRelation(minLevel int, mapTagLevel map[string]*types.TagItem, productList []gmodel.FsProduct, mapTagProduct map[int64]types.TagProduct) (rspTagList []types.TagItem, mapTagRsp map[int64]types.TagItem, productCount int) {
|
func (l *GetTagProductListLogic) organizationLevelRelation(minLevel int, mapTagLevel map[string]*types.TagItem, productList []gmodel.FsProduct, mapTagProduct map[int64]types.TagProduct) (mapTagRsp map[int64]types.TagItem, productCount int) {
|
||||||
mapTop := make(map[string]struct{})
|
mapTop := make(map[string]struct{})
|
||||||
mapTagRsp = make(map[int64]types.TagItem)
|
mapTagRsp = make(map[int64]types.TagItem)
|
||||||
//设置归属关系
|
//设置归属关系
|
||||||
@ -371,21 +370,21 @@ func (l *GetTagProductListLogic) organizationLevelRelation(minLevel int, mapTagL
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
//最终值提取最高级别那一层出来
|
//最终值提取最高级别那一层出来
|
||||||
rspList := make([]types.TagItem, 0, len(mapTagLevel))
|
//rspList := make([]types.TagItem, 0, len(mapTagLevel))
|
||||||
for prefix, _ := range mapTop {
|
for prefix, _ := range mapTop {
|
||||||
//大类下没有任何产品则不显示
|
//大类下没有任何产品则不显示
|
||||||
if len(mapTagLevel[prefix].TagProductList) == 0 {
|
if len(mapTagLevel[prefix].TagProductList) == 0 {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
productCount += len(mapTagLevel[prefix].TagProductList)
|
productCount += len(mapTagLevel[prefix].TagProductList)
|
||||||
rspList = append(rspList, *mapTagLevel[prefix])
|
//rspList = append(rspList, *mapTagLevel[prefix])
|
||||||
mapTagRsp[mapTagLevel[prefix].TypeId] = *mapTagLevel[prefix]
|
mapTagRsp[mapTagLevel[prefix].TypeId] = *mapTagLevel[prefix]
|
||||||
}
|
}
|
||||||
//排序
|
//排序
|
||||||
sort.SliceStable(rspList, func(i, j int) bool {
|
/*sort.SliceStable(rspList, func(i, j int) bool {
|
||||||
return rspList[i].Sort < rspList[j].Sort
|
return rspList[i].Sort < rspList[j].Sort
|
||||||
})
|
})*/
|
||||||
return rspList, mapTagRsp, productCount
|
return mapTagRsp, productCount
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取某个tag的直属产品
|
// 获取某个tag的直属产品
|
||||||
|
@ -36,7 +36,6 @@ type GetTagProductListReq struct {
|
|||||||
|
|
||||||
type GetTagProductListRsp struct {
|
type GetTagProductListRsp struct {
|
||||||
TotalCategoryProduct int `json:"total_category_product"`
|
TotalCategoryProduct int `json:"total_category_product"`
|
||||||
TagList []TagItem `json:"tag_list"`
|
|
||||||
TagMap interface{} `json:"tag_map"`
|
TagMap interface{} `json:"tag_map"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,7 +78,6 @@ type GetTagProductListReq {
|
|||||||
}
|
}
|
||||||
type GetTagProductListRsp {
|
type GetTagProductListRsp {
|
||||||
TotalCategoryProduct int `json:"total_category_product"`
|
TotalCategoryProduct int `json:"total_category_product"`
|
||||||
TagList []TagItem `json:"tag_list"`
|
|
||||||
TagMap interface{} `json:"tag_map"`
|
TagMap interface{} `json:"tag_map"`
|
||||||
}
|
}
|
||||||
type TagItem {
|
type TagItem {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user