This commit is contained in:
laodaming 2023-07-20 18:06:48 +08:00
parent 0e752e31fd
commit 10aa0d14f0

View File

@ -56,16 +56,14 @@ func (l *GetRecommandProductListLogic) GetRecommandProductList(req *types.GetRec
ignoreProductIds := make([]int64, 0, len(recommendProductList)+1)
ignoreProductIds = append(ignoreProductIds, productInfo.Id)
productIds := make([]int64, 0, len(recommendProductList))
for _, v := range recommendProductList {
ignoreProductIds = append(ignoreProductIds, v.Id)
productIds = append(productIds, v.Id)
}
//在合并之前记住推荐的产品
mapRecommend := make(map[int64]struct{})
for _, v := range recommendProductList {
ignoreProductIds = append(ignoreProductIds, v.Id)
productIds = append(productIds, v.Id)
mapRecommend[v.Id] = struct{}{}
}
//小于请求的数量则需要从产品表中随机填补上
//小于请求的数量则需要从产品表中随机填补上(不包含上面的产品)
lenRecommendProduct := len(recommendProductList)
if lenRecommendProduct < int(req.Num) {
appendNum := int(req.Num) - lenRecommendProduct