Merge branch 'develop' of https://gitee.com/fusenpack/fusenapi into develop
This commit is contained in:
commit
406d62a894
|
@ -52,12 +52,12 @@ func (a *FsAddressModel) CreateOne(ctx context.Context, address *FsAddress) (res
|
||||||
func (a *FsAddressModel) UpdateAddAddress(ctx context.Context, address *FsAddress) (err error) {
|
func (a *FsAddressModel) UpdateAddAddress(ctx context.Context, address *FsAddress) (err error) {
|
||||||
err = a.db.WithContext(ctx).Transaction(func(tx *gorm.DB) error {
|
err = a.db.WithContext(ctx).Transaction(func(tx *gorm.DB) error {
|
||||||
if *address.IsDefault > 0 {
|
if *address.IsDefault > 0 {
|
||||||
err = tx.Where("user_id = ? and is_default = 1", address.UserId).Update("is_default", 0).Error
|
err = tx.Model(&FsAddress{}).Where("user_id = ? and is_default = 1 ", address.UserId).Update("is_default", 0).Error
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return a.db.WithContext(ctx).Where("id = ? and user_id = ?", address.Id, address.UserId).Omit("id", "user_id").Updates(address).Error
|
return tx.Model(&FsAddress{}).Where("id = ? and user_id = ?", address.Id, address.UserId).Omit("id", "user_id").Updates(address).Error
|
||||||
})
|
})
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -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)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user