This commit is contained in:
laodaming
2023-07-20 18:18:36 +08:00
parent 10aa0d14f0
commit 532929a563
3 changed files with 5 additions and 2 deletions

View File

@@ -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