diff --git a/constants/recommend_product.go b/constants/recommend_product.go index 68717ba3..81496ee7 100644 --- a/constants/recommend_product.go +++ b/constants/recommend_product.go @@ -6,4 +6,4 @@ type recommend_product int64 const PRODUCT_DETAIL_RECOMMEND_CATEGORY recommend_product = 1 // 主页推荐产品 -const HOME_PAGE_RECOMMEND_CATEGORY recommend_product = 1 +const HOME_PAGE_RECOMMEND_CATEGORY recommend_product = 2 diff --git a/model/gmodel/fs_product_recommend_logic.go b/model/gmodel/fs_product_recommend_logic.go index d4cae34d..71e9f4aa 100644 --- a/model/gmodel/fs_product_recommend_logic.go +++ b/model/gmodel/fs_product_recommend_logic.go @@ -14,7 +14,7 @@ type GetRecommendProductListReq struct { } func (r *FsProductRecommendModel) GetRecommendProductList(req GetRecommendProductListReq) (resp []FsProduct, total int64, err error) { - db := r.db.WithContext(req.Ctx).Select("p.*"). + db := r.db.WithContext(req.Ctx). Table("fs_product_recommend as r"). Joins("inner join fs_product as p on r.product_id = p.id"). Where("r.status = ? ", 1). @@ -25,6 +25,7 @@ func (r *FsProductRecommendModel) GetRecommendProductList(req GetRecommendProduc if err = db.Limit(1).Count(&total).Error; err != nil { return nil, 0, err } + db = db.Select("p.*") offset := (req.Page - 1) * req.Limit err = db.Offset(offset).Limit(req.Limit).Find(&resp).Error return resp, total, err diff --git a/server/product/internal/logic/homepagerecommendproductlistlogic.go b/server/product/internal/logic/homepagerecommendproductlistlogic.go index fdbd0240..f4b88d65 100644 --- a/server/product/internal/logic/homepagerecommendproductlistlogic.go +++ b/server/product/internal/logic/homepagerecommendproductlistlogic.go @@ -2,6 +2,7 @@ package logic import ( "errors" + "fmt" "fusenapi/constants" "fusenapi/model/gmodel" "fusenapi/utils/auth" @@ -62,6 +63,7 @@ func (l *HomePageRecommendProductListLogic) HomePageRecommendProductList(req *ty if len(recommendProductList) == 0 { return resp.SetStatusWithMessage(basic.CodeOK, "success", []interface{}{}) } + fmt.Println(recommendProductList) productIds := make([]int64, 0, len(recommendProductList)) for _, product := range recommendProductList { productIds = append(productIds, product.Id)