fusenapi/model/gmodel/fs_product_design_logic.go

37 lines
1.3 KiB
Go
Raw Normal View History

2023-06-16 07:11:37 +00:00
package gmodel
import (
"context"
)
2023-06-20 09:28:28 +00:00
func (d *FsProductDesignModel) FindOneBySn(ctx context.Context, sn string, userId int64) (resp *FsProductDesign, err error) {
2023-06-19 04:23:02 +00:00
err = d.db.WithContext(ctx).Model(&FsProductDesign{}).Where("`sn` = ? and `user_id` = ? and `status` = ?", sn, userId, 1).First(&resp).Error
2023-06-20 09:28:28 +00:00
return resp, err
2023-06-16 07:11:37 +00:00
}
func (d *FsProductDesignModel) GetAllByIds(ctx context.Context, ids []int64) (resp []FsProductDesign, err error) {
if len(ids) == 0 {
return
}
err = d.db.WithContext(ctx).Model(&FsProductDesign{}).Where("`id` in (?) and `status` = ?", ids, 1).Find(&resp).Error
if err != nil {
return nil, err
}
return
}
2023-06-27 10:35:26 +00:00
func (d *FsProductDesignModel) GetAllByIdsWithoutStatus(ctx context.Context, ids []int64) (resp []FsProductDesign, err error) {
if len(ids) == 0 {
return
}
err = d.db.WithContext(ctx).Model(&FsProductDesign{}).Where("`id` in (?)", ids).Find(&resp).Error
if err != nil {
return nil, err
}
return
}
2023-06-30 09:20:11 +00:00
func (d *FsProductDesignModel) Create(ctx context.Context, data *FsProductDesign) error {
return d.db.WithContext(ctx).Model(&FsProductDesign{}).Create(&data).Error
}
2023-07-05 08:03:16 +00:00
func (d *FsProductDesignModel) UpdateBySn(ctx context.Context, sn string, data *FsProductDesign) error {
return d.db.WithContext(ctx).Model(&FsProductDesign{}).Where("`sn` = ?", sn).Updates(&data).Error
}