This commit is contained in:
laodaming
2023-08-17 18:19:15 +08:00
parent 68b125f5a6
commit f892a216d6
6 changed files with 16 additions and 9 deletions

View File

@@ -4,11 +4,14 @@ import (
"context"
)
func (t *FsProductTemplateV2Model) FindAllByProductIds(ctx context.Context, productIds []int64, fields ...string) (resp []FsProductTemplateV2, err error) {
func (t *FsProductTemplateV2Model) FindAllByProductIds(ctx context.Context, productIds []int64, sort string, fields ...string) (resp []FsProductTemplateV2, err error) {
if len(productIds) == 0 {
return
}
db := t.db.WithContext(ctx).Model(&FsProductTemplateV2{}).Where("`product_id` in (?) and `is_del` = ? and `status` = ?", productIds, 0, 1)
if sort != "" {
db = db.Order(sort)
}
if len(fields) != 0 {
db = db.Select(fields[0])
}