This commit is contained in:
laodaming
2023-07-10 19:42:55 +08:00
parent f9bfbf28ae
commit f07e4a2084
6 changed files with 181 additions and 4 deletions

View File

@@ -64,13 +64,15 @@ func (p *FsProductModel) GetProductListByTypeIds(ctx context.Context, productTyp
func (p *FsProductModel) GetRandomProductList(ctx context.Context, limit int) (resp []FsProduct, err error) {
err = p.db.WithContext(ctx).Model(&FsProduct{}).
Where("`is_del` =? and `is_shelf` = ?", 0, 1).Order("RAND()").Limit(limit).Find(&resp).Error
if err != nil {
return nil, err
}
return
return resp,err
}
func (p *FsProductModel) FindAllOnlyByIds(ctx context.Context, ids []int64) (resp []*FsProduct, err error) {
err = p.db.WithContext(ctx).Model(&FsProduct{}).Where("`id` IN (?)", ids).Find(&resp).Error
return resp, err
}
func (p *FsProductModel) GetRandomProductListInIds(ctx context.Context,ids []int64, limit int) (resp []FsProduct, err error) {
err = p.db.WithContext(ctx).Model(&FsProduct{}).
Where("`id` in (?) and `is_del` =? and `is_shelf` = ?", ids,0, 1).Order("RAND()").Limit(limit).Find(&resp).Error
return resp,err
}