fix
This commit is contained in:
@@ -2,7 +2,7 @@ package logic
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fusenapi/constants"
|
||||
"fusenapi/model/gmodel"
|
||||
"fusenapi/utils/auth"
|
||||
"fusenapi/utils/basic"
|
||||
"fusenapi/utils/format"
|
||||
@@ -46,15 +46,23 @@ func (l *GetRecommandProductListLogic) GetRecommandProductList(req *types.GetRec
|
||||
logx.Error(err)
|
||||
return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get detail product info")
|
||||
}
|
||||
//随机取产品列表(不包含详情产品)
|
||||
recommendProductList, err := l.svcCtx.AllModels.FsProductRecommend.GetIgnoreRandomRecommendProductList(l.ctx, int(req.Num), int64(constants.PRODUCT_DETAIL_RECOMMEND_CATEGORY), []int64{productInfo.Id})
|
||||
if err != nil {
|
||||
logx.Error(err)
|
||||
return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get random recommend list")
|
||||
var (
|
||||
recommendProductList []gmodel.FsProduct
|
||||
)
|
||||
if productInfo.RecommendProduct != nil && *productInfo.RecommendProduct != "" {
|
||||
recommendProductIds, err := format.StrSlicToInt64Slice(strings.Split(*productInfo.RecommendProduct, ","))
|
||||
if err != nil {
|
||||
logx.Error(err)
|
||||
return resp.SetStatusWithMessage(basic.CodeServiceErr, "failed to split recommend product ids")
|
||||
}
|
||||
recommendProductList, err = l.svcCtx.AllModels.FsProduct.GetProductListByIds(l.ctx, recommendProductIds, "")
|
||||
if err != nil {
|
||||
logx.Error(err)
|
||||
return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get recommend product list")
|
||||
}
|
||||
}
|
||||
//需要填充时需要忽略的id
|
||||
ignoreProductIds := make([]int64, 0, len(recommendProductList)+1)
|
||||
ignoreProductIds = append(ignoreProductIds, productInfo.Id)
|
||||
ignoreProductIds := make([]int64, 0, len(recommendProductList))
|
||||
productIds := make([]int64, 0, len(recommendProductList))
|
||||
//在合并之前记住推荐的产品
|
||||
mapRecommend := make(map[int64]struct{})
|
||||
|
||||
@@ -3,7 +3,6 @@ package logic
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"fusenapi/constants"
|
||||
"fusenapi/model/gmodel"
|
||||
"fusenapi/utils/auth"
|
||||
"fusenapi/utils/basic"
|
||||
@@ -55,10 +54,9 @@ func (l *HomePageRecommendProductListLogic) HomePageRecommendProductList(req *ty
|
||||
)
|
||||
//获取列表推荐产品
|
||||
recommendProductList, _, err = l.svcCtx.AllModels.FsProductRecommend.GetRecommendProductList(gmodel.GetRecommendProductListReq{
|
||||
Ctx: l.ctx,
|
||||
Page: 1,
|
||||
Limit: 500, //设置最大500
|
||||
Category: int64(constants.HOME_PAGE_RECOMMEND_CATEGORY),
|
||||
Ctx: l.ctx,
|
||||
Page: 1,
|
||||
Limit: 500, //设置最大500
|
||||
})
|
||||
if len(recommendProductList) == 0 {
|
||||
return resp.SetStatusWithMessage(basic.CodeOK, "success", []interface{}{})
|
||||
|
||||
Reference in New Issue
Block a user