fix
This commit is contained in:
parent
10aa0d14f0
commit
532929a563
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue
Block a user