34 lines
1.3 KiB
Go
Executable File
34 lines
1.3 KiB
Go
Executable File
package gmodel
|
|
|
|
import "context"
|
|
|
|
func (l *FsProductModel3dLightModel) GetAllByIds(ctx context.Context, ids []int64) (resp []FsProductModel3dLight, err error) {
|
|
if len(ids) == 0 {
|
|
return
|
|
}
|
|
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
|
|
}
|
|
|
|
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
|
|
}
|
|
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
|
|
}
|