fix
wangpengfei
2023-08-25 c20b2d72c1f6241213f792dde44e50def6bf3510
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