fusenapi/model/gmodel/fs_product_model3d_logic.go
laodaming 6a9650b9d1 fix
2023-06-19 14:47:54 +08:00

36 lines
1.0 KiB
Go
Executable File

package gmodel
import (
"context"
"errors"
"gorm.io/gorm"
)
func (d *FsProductModel3dModel) FindOne(ctx context.Context, id int64) (resp FsProductModel3d, err error) {
err = d.db.WithContext(ctx).Model(&FsProductModel3d{}).Where("`id` = ? ", id).Find(&resp).Error
if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) {
return FsProductModel3d{}, err
}
return resp, nil
}
func (d *FsProductModel3dModel) GetAllByIds(ctx context.Context, ids []int64) (resp []FsProductModel3d, err error) {
if len(ids) == 0 {
return
}
err = d.db.WithContext(ctx).Model(&FsProductModel3d{}).Where("`id` in (?) and `status` = ?", ids, 1).Find(&resp).Error
if err != nil {
return nil, err
}
return
}
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
if err != nil {
return nil, err
}
return
}