fix
Batch Update suupplier_type
| | |
| | | if err := iService.CreateIndustry(&industry); err != nil { |
| | | global.GVA_LOG.Error("更新失败!", zap.Error(err)) |
| | | response.FailWithMessage("保存失败", c) |
| | | return |
| | | } |
| | | } |
| | | |
| | | if err == nil { |
| | | response.OkWithMessage("更新成功", c) |
| | | } |
| | | response.OkWithMessage("更新成功", c) |
| | | } |
| | | |
| | | // FindIndustry 用id查询Industry |
| | |
| | | // @Security ApiKeyAuth |
| | | // @accept application/json |
| | | // @Produce application/json |
| | | // @Param data body test.SupplierType true "更新SupplierType" |
| | | // @Param data body request.SupplierTypeList true "更新SupplierType" |
| | | // @Success 200 {string} string "{"success":true,"data":{},"msg":"更新成功"}" |
| | | // @Router /st/updateSupplierType [put] |
| | | func (stApi *SupplierTypeApi) UpdateSupplierType(c *gin.Context) { |
| | | var st test.SupplierType |
| | | var st testReq.SupplierTypeList |
| | | err := c.ShouldBindJSON(&st) |
| | | if err != nil { |
| | | response.FailWithMessage(err.Error(), c) |
| | | return |
| | | } |
| | | if err := stService.UpdateSupplierType(st); err != nil { |
| | | global.GVA_LOG.Error("更新失败!", zap.Error(err)) |
| | | response.FailWithMessage("更新失败", c) |
| | | } else { |
| | | response.OkWithMessage("更新成功", c) |
| | | |
| | | if err := stService.DeleteAll(); err != nil { |
| | | global.GVA_LOG.Error("删除失败!", zap.Error(err)) |
| | | response.FailWithMessage("删除失败", c) |
| | | return |
| | | } |
| | | |
| | | for _, v := range st.SupplierTypes { |
| | | if err := stService.CreateSupplierType(&v); err != nil { |
| | | global.GVA_LOG.Error("创建失败!", zap.Error(err)) |
| | | response.FailWithMessage("创建失败", c) |
| | | return |
| | | } |
| | | } |
| | | |
| | | response.OkWithMessage("更新成功", c) |
| | | } |
| | | |
| | | // FindSupplierType 用id查询SupplierType |
| | |
| | | "in": "body", |
| | | "required": true, |
| | | "schema": { |
| | | "$ref": "#/definitions/test.SupplierType" |
| | | "$ref": "#/definitions/request.SupplierTypeList" |
| | | } |
| | | } |
| | | ], |
| | |
| | | } |
| | | } |
| | | }, |
| | | "request.SupplierTypeList": { |
| | | "type": "object", |
| | | "properties": { |
| | | "supplierTypes": { |
| | | "type": "array", |
| | | "items": { |
| | | "$ref": "#/definitions/test.SupplierType" |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "request.SysAuthorityBtnReq": { |
| | | "type": "object", |
| | | "properties": { |
| | |
| | | "in": "body", |
| | | "required": true, |
| | | "schema": { |
| | | "$ref": "#/definitions/test.SupplierType" |
| | | "$ref": "#/definitions/request.SupplierTypeList" |
| | | } |
| | | } |
| | | ], |
| | |
| | | } |
| | | } |
| | | }, |
| | | "request.SupplierTypeList": { |
| | | "type": "object", |
| | | "properties": { |
| | | "supplierTypes": { |
| | | "type": "array", |
| | | "items": { |
| | | "$ref": "#/definitions/test.SupplierType" |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "request.SysAuthorityBtnReq": { |
| | | "type": "object", |
| | | "properties": { |
| | |
| | | status: |
| | | type: integer |
| | | type: object |
| | | request.SupplierTypeList: |
| | | properties: |
| | | supplierTypes: |
| | | items: |
| | | $ref: '#/definitions/test.SupplierType' |
| | | type: array |
| | | type: object |
| | | request.SysAuthorityBtnReq: |
| | | properties: |
| | | authorityId: |
| | |
| | | name: data |
| | | required: true |
| | | schema: |
| | | $ref: '#/definitions/test.SupplierType' |
| | | $ref: '#/definitions/request.SupplierTypeList' |
| | | produces: |
| | | - application/json |
| | | responses: |
| | |
| | | EndCreatedAt *time.Time `json:"endCreatedAt" form:"endCreatedAt"` |
| | | request.PageInfo |
| | | } |
| | | |
| | | type SupplierTypeList struct { |
| | | SupplierTypes []test.SupplierType `json:"supplierTypes"` |
| | | } |
| | |
| | | err = db.Limit(limit).Offset(offset).Find(&sts).Error |
| | | return sts, total, err |
| | | } |
| | | |
| | | func (stService *SupplierTypeService) DeleteAll() (err error) { |
| | | err = global.GVA_DB.Where("1=1").Delete(&[]test.SupplierType{}).Error |
| | | return err |
| | | } |