This commit is contained in:
laodaming 2023-07-11 15:01:08 +08:00
parent 8e207ef600
commit bb18b5effa

View File

@ -74,17 +74,17 @@ func (t *FsProductTemplateV2Model) FindOneByModelId(ctx context.Context, modelId
} }
type GetProductTemplateListByParamsReq struct { type GetProductTemplateListByParamsReq struct {
ProductIds []int64 ProductIds []int64 //必传哦
GroupBy string GroupBy string
OrderBy string OrderBy string
Fields string Fields string
Status *int64 Status *int64
} }
func (t *FsProductTemplateV2Model) GetProductTemplateListByParams(ctx context.Context, req GetProductTemplateListByParamsReq) (resp []FsProductTemplateV2, err error) { func (t *FsProductTemplateV2Model) GetProductTemplateListByParams(ctx context.Context, req GetProductTemplateListByParamsReq) (resp []FsProductTemplateV2, err error) {
db := t.db.WithContext(ctx).Model(&FsProductTemplateV2{}) if len(req.ProductIds) == 0{
if len(req.ProductIds) > 0{ return
db = db.Where("`product_id` in (?)",req.ProductIds)
} }
db := t.db.WithContext(ctx).Model(&FsProductTemplateV2{}).Where("`product_id` in (?)",req.ProductIds)
if req.GroupBy != ""{ if req.GroupBy != ""{
db = db.Group(req.GroupBy) db = db.Group(req.GroupBy)
} }