This commit is contained in:
laodaming
2023-08-08 17:03:54 +08:00
parent 584498f556
commit 2f1ef81263
4 changed files with 31 additions and 6 deletions

View File

@@ -57,6 +57,9 @@ func (t *FsProductTemplateV2Model) FindAllByModelIds(ctx context.Context, modelI
return
}
db := t.db.WithContext(ctx).Model(&FsProductTemplateV2{}).Where("`model_id` in (?) and `is_del` = ? and `status` = ?", modelIds, 0, 1)
if len(fields) != 0 {
db = db.Select(fields[0])
}
switch orderBy {
case "":
db = db.Order("id DESC")
@@ -119,3 +122,20 @@ func (t *FsProductTemplateV2Model) FindOneByProductIdTagIdWithSizeTable(ctx cont
Take(&resp).Error
return resp, err
}
func (t *FsProductTemplateV2Model) FindAllByModelIdsTemplateTag(ctx context.Context, modelIds []int64, templateTag string, orderBy string, fields ...string) (resp []FsProductTemplateV2, err error) {
if len(modelIds) == 0 {
return
}
db := t.db.WithContext(ctx).Model(&FsProductTemplateV2{}).Where("`model_id` in (?) and `tag` = ? and `is_del` = ? and `status` = ?", modelIds, templateTag, 0, 1)
if len(fields) != 0 {
db = db.Select(fields[0])
}
switch orderBy {
case "":
db = db.Order("id DESC")
default:
db = db.Order(orderBy)
}
err = db.Find(&resp).Error
return resp, err
}