fix
wangpengfei
2023-08-25 c20b2d72c1f6241213f792dde44e50def6bf3510
fix

Batch Update suupplier_type
7个文件已修改
71 ■■■■ 已修改文件
api/v1/test/industry.go 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
api/v1/test/supplier_type.go 24 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
docs/docs.go 13 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
docs/swagger.json 13 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
docs/swagger.yaml 9 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
model/test/request/supplier_type.go 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
service/test/supplier_type.go 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
api/v1/test/industry.go
@@ -116,12 +116,11 @@
        if err := iService.CreateIndustry(&industry); err != nil {
            global.GVA_LOG.Error("更新失败!", zap.Error(err))
            response.FailWithMessage("保存失败", c)
            return
        }
    }
    if err == nil {
        response.OkWithMessage("更新成功", c)
    }
}
// FindIndustry 用id查询Industry
api/v1/test/supplier_type.go
@@ -94,22 +94,32 @@
// @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
docs/docs.go
@@ -4312,7 +4312,7 @@
                        "in": "body",
                        "required": true,
                        "schema": {
                            "$ref": "#/definitions/test.SupplierType"
                            "$ref": "#/definitions/request.SupplierTypeList"
                        }
                    }
                ],
@@ -7312,6 +7312,17 @@
                }
            }
        },
        "request.SupplierTypeList": {
            "type": "object",
            "properties": {
                "supplierTypes": {
                    "type": "array",
                    "items": {
                        "$ref": "#/definitions/test.SupplierType"
                    }
                }
            }
        },
        "request.SysAuthorityBtnReq": {
            "type": "object",
            "properties": {
docs/swagger.json
@@ -4303,7 +4303,7 @@
                        "in": "body",
                        "required": true,
                        "schema": {
                            "$ref": "#/definitions/test.SupplierType"
                            "$ref": "#/definitions/request.SupplierTypeList"
                        }
                    }
                ],
@@ -7303,6 +7303,17 @@
                }
            }
        },
        "request.SupplierTypeList": {
            "type": "object",
            "properties": {
                "supplierTypes": {
                    "type": "array",
                    "items": {
                        "$ref": "#/definitions/test.SupplierType"
                    }
                }
            }
        },
        "request.SysAuthorityBtnReq": {
            "type": "object",
            "properties": {
docs/swagger.yaml
@@ -897,6 +897,13 @@
      status:
        type: integer
    type: object
  request.SupplierTypeList:
    properties:
      supplierTypes:
        items:
          $ref: '#/definitions/test.SupplierType'
        type: array
    type: object
  request.SysAuthorityBtnReq:
    properties:
      authorityId:
@@ -4035,7 +4042,7 @@
        name: data
        required: true
        schema:
          $ref: '#/definitions/test.SupplierType'
          $ref: '#/definitions/request.SupplierTypeList'
      produces:
      - application/json
      responses:
model/test/request/supplier_type.go
@@ -12,3 +12,7 @@
    EndCreatedAt   *time.Time `json:"endCreatedAt" form:"endCreatedAt"`
    request.PageInfo
}
type SupplierTypeList struct {
    SupplierTypes []test.SupplierType `json:"supplierTypes"`
}
service/test/supplier_type.go
@@ -65,3 +65,8 @@
    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
}