fix
This commit is contained in:
parent
bd07bf3264
commit
a240d9a3e3
|
@ -88,9 +88,9 @@ func (p *FsProductModel) GetRandomProductList(ctx context.Context, limit int) (r
|
||||||
Where("`is_del` =? and `is_shelf` = ?", 0, 1).Order("RAND()").Limit(limit).Find(&resp).Error
|
Where("`is_del` =? and `is_shelf` = ?", 0, 1).Order("RAND()").Limit(limit).Find(&resp).Error
|
||||||
return resp, err
|
return resp, err
|
||||||
}
|
}
|
||||||
func (p *FsProductModel) GetIgnoreRandomProductList(ctx context.Context, limit int, notInProductIds []int64) (resp []FsProduct, err error) {
|
func (p *FsProductModel) GetIgnoreRandomProductList(ctx context.Context, category int, limit int, notInProductIds []int64) (resp []FsProduct, err error) {
|
||||||
db := p.db.WithContext(ctx).Model(&FsProduct{}).
|
db := p.db.WithContext(ctx).Model(&FsProduct{}).
|
||||||
Where("`is_del` =? and `is_shelf` = ? ", 0, 1)
|
Where("`is_del` =? and `is_shelf` = ? and `category` = ?", 0, 1, category)
|
||||||
if len(notInProductIds) > 0 {
|
if len(notInProductIds) > 0 {
|
||||||
db = db.Where("`id` not in(?)", notInProductIds)
|
db = db.Where("`id` not in(?)", notInProductIds)
|
||||||
}
|
}
|
||||||
|
|
|
@ -84,7 +84,7 @@ func (l *GetRecommendProductListLogic) GetRecommendProductList(req *types.GetRec
|
||||||
lenRecommendProduct := len(recommendProductList)
|
lenRecommendProduct := len(recommendProductList)
|
||||||
if lenRecommendProduct < int(req.Num) {
|
if lenRecommendProduct < int(req.Num) {
|
||||||
appendNum := int(req.Num) - lenRecommendProduct
|
appendNum := int(req.Num) - lenRecommendProduct
|
||||||
productList, err := l.svcCtx.AllModels.FsProduct.GetIgnoreRandomProductList(l.ctx, appendNum, ignoreProductIds)
|
productList, err := l.svcCtx.AllModels.FsProduct.GetIgnoreRandomProductList(l.ctx, 1, appendNum, ignoreProductIds)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logx.Error(err)
|
logx.Error(err)
|
||||||
return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get product list")
|
return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get product list")
|
||||||
|
|
Loading…
Reference in New Issue
Block a user