diff --git a/server/product/internal/logic/getrecommandproductlistlogic.go b/server/product/internal/logic/getrecommandproductlistlogic.go index 4e86ec57..103134a0 100644 --- a/server/product/internal/logic/getrecommandproductlistlogic.go +++ b/server/product/internal/logic/getrecommandproductlistlogic.go @@ -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