This commit is contained in:
laodaming
2023-10-25 18:21:06 +08:00
parent 075f89df49
commit 76412c96ce
2 changed files with 8 additions and 2 deletions

View File

@@ -89,8 +89,12 @@ func (p *FsProductModel) GetRandomProductList(ctx context.Context, limit int) (r
return resp, err
}
func (p *FsProductModel) GetIgnoreRandomProductList(ctx context.Context, limit int, notInProductIds []int64) (resp []FsProduct, err error) {
err = p.db.WithContext(ctx).Model(&FsProduct{}).
Where("`is_del` =? and `is_shelf` = ? and `id` not in(?)", 0, 1, notInProductIds).Order("RAND()").Limit(limit).Find(&resp).Error
db := p.db.WithContext(ctx).Model(&FsProduct{}).
Where("`is_del` =? and `is_shelf` = ? ", 0, 1)
if len(notInProductIds) > 0 {
db = db.Where("`id` not in(?)", notInProductIds)
}
err = db.Order("RAND()").Limit(limit).Find(&resp).Error
return resp, err
}
func (p *FsProductModel) FindAllOnlyByIds(ctx context.Context, ids []int64) (resp []FsProduct, err error) {