This commit is contained in:
laodaming
2023-07-17 14:40:24 +08:00
parent fffdf448c4
commit 73ce1e6db3
8 changed files with 258 additions and 6 deletions

View File

@@ -52,15 +52,19 @@ func (t *FsProductTemplateV2Model) FindByParam(ctx context.Context, id int64, mo
func (t *FsProductTemplateV2Model) Update(ctx context.Context, id int64, data *FsProductTemplateV2) error {
return t.db.WithContext(ctx).Model(&FsProductTemplateV2{}).Where("`id` = ? ", id).Updates(&data).Error
}
func (t *FsProductTemplateV2Model) FindAllByModelIds(ctx context.Context, modelIds []int64) (resp []FsProductTemplateV2, err error) {
func (t *FsProductTemplateV2Model) FindAllByModelIds(ctx context.Context, modelIds []int64, orderBy string, fields ...string) (resp []FsProductTemplateV2, err error) {
if len(modelIds) == 0 {
return
}
err = t.db.WithContext(ctx).Model(&FsProductTemplateV2{}).Where("`model_id` in (?) and `is_del` = ? and `status` = ?", modelIds, 0, 1).Find(&resp).Error
if err != nil {
return nil, err
db := t.db.WithContext(ctx).Model(&FsProductTemplateV2{}).Where("`model_id` in (?) and `is_del` = ? and `status` = ?", modelIds, 0, 1)
switch orderBy {
case "":
db = db.Order("id DESC")
default:
db = db.Order(orderBy)
}
return
err = db.Find(&resp).Error
return resp, err
}
func (t *FsProductTemplateV2Model) FindAllByProductIdModelIds(ctx context.Context, modelIds []int64, productId int64) (resp []FsProductTemplateV2, err error) {
if len(modelIds) == 0 {