fusenapi/model/gmodel/fs_product_model3d_logic.go

29 lines
958 B
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 *FsProductModel3dModel) FindOne(ctx context.Context, id int64) (resp *FsProductModel3d, err error) {
2023-06-19 06:47:54 +00:00
err = d.db.WithContext(ctx).Model(&FsProductModel3d{}).Where("`id` = ? ", id).Find(&resp).Error
2023-06-20 09:28:28 +00:00
return resp, err
2023-06-19 06:47:54 +00:00
}
2023-06-21 04:11:43 +00:00
func (d *FsProductModel3dModel) GetAllByIds(ctx context.Context, ids []int64, fields ...string) (resp []FsProductModel3d, err error) {
2023-06-16 07:11:37 +00:00
if len(ids) == 0 {
return
}
2023-06-21 04:11:43 +00:00
db := d.db.WithContext(ctx).Model(&FsProductModel3d{}).Where("`id` in (?) and `status` = ?", ids, 1)
if len(fields) > 0 {
db = db.Select(fields[0])
2023-06-16 07:11:37 +00:00
}
2023-06-21 04:11:43 +00:00
err = db.Find(&resp).Error
return resp, err
2023-06-16 07:11:37 +00:00
}
func (d *FsProductModel3dModel) GetAllByIdsTag(ctx context.Context, ids []int64, tag int64) (resp []FsProductModel3d, err error) {
if len(ids) == 0 {
return
}
err = d.db.WithContext(ctx).Model(&FsProductModel3d{}).Where("`id` in (?) and `status` = ? and `tag` = ?", ids, 1, tag).Find(&resp).Error
2023-06-21 04:11:43 +00:00
return resp, err
2023-06-16 07:11:37 +00:00
}