2023-06-16 07:11:37 +00:00
|
|
|
package gmodel
|
2023-06-20 11:56:18 +00:00
|
|
|
|
|
|
|
import "context"
|
|
|
|
|
2023-09-20 02:31:36 +00:00
|
|
|
func (l *FsProductModel3dLightModel) FindOne(ctx context.Context, id int64) (resp *FsProductModel3dLight, err error) {
|
|
|
|
err = l.db.WithContext(ctx).Model(&FsProductModel3dLight{}).Where("`id` = ? and `status` = ?", id, 1).Take(&resp).Error
|
|
|
|
return resp, err
|
|
|
|
}
|
2023-06-20 11:56:18 +00:00
|
|
|
func (l *FsProductModel3dLightModel) GetAllByIds(ctx context.Context, ids []int64) (resp []FsProductModel3dLight, err error) {
|
2023-07-04 08:48:56 +00:00
|
|
|
if len(ids) == 0 {
|
|
|
|
return
|
|
|
|
}
|
2023-06-25 09:11:42 +00:00
|
|
|
err = l.db.WithContext(ctx).Model(&FsProductModel3dLight{}).Where("`id` in (?) and `status` = ?", ids, 1).Find(&resp).Error
|
|
|
|
return resp, err
|
|
|
|
}
|
|
|
|
func (l *FsProductModel3dLightModel) GetAll(ctx context.Context) (resp []FsProductModel3dLight, err error) {
|
|
|
|
err = l.db.WithContext(ctx).Model(&FsProductModel3dLight{}).Where("`status` = ?", 1).Find(&resp).Error
|
|
|
|
return resp, err
|
2023-06-20 11:56:18 +00:00
|
|
|
}
|
2023-06-26 08:53:36 +00:00
|
|
|
|
|
|
|
func (l *FsProductModel3dLightModel) Create(ctx context.Context, data *FsProductModel3dLight) error {
|
|
|
|
return l.db.WithContext(ctx).Create(&data).Error
|
|
|
|
}
|
|
|
|
func (l *FsProductModel3dLightModel) Update(ctx context.Context, id int64, data *FsProductModel3dLight) error {
|
|
|
|
return l.db.WithContext(ctx).Where("`id` = ?", id).Updates(data).Error
|
|
|
|
}
|
2023-07-04 08:48:56 +00:00
|
|
|
func (l *FsProductModel3dLightModel) GetAllByIdsWithoutStatus(ctx context.Context, ids []int64, fields ...string) (resp []FsProductModel3dLight, err error) {
|
|
|
|
if len(ids) == 0 {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
db := l.db.WithContext(ctx).Model(&FsProductModel3dLight{}).Where("`id` in (?)", ids)
|
|
|
|
if len(fields) != 0 {
|
|
|
|
db = db.Select(fields[0])
|
|
|
|
}
|
|
|
|
err = db.Find(&resp).Error
|
|
|
|
return resp, err
|
|
|
|
}
|