fix
wangpengfei
2023-08-25 c2e727dcdfa8970f629c3e3884bd866398bf3f48
api/v1/test/industry.go
@@ -94,20 +94,32 @@
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body test.Industry true "更新Industry"
// @Param data body request.IndustryList true "更新Industry"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"更新成功"}"
// @Router /i/updateIndustry [put]
func (iApi *IndustryApi) UpdateIndustry(c *gin.Context) {
   var i test.Industry
   var i testReq.IndustryList
   err := c.ShouldBindJSON(&i)
   if err != nil {
      response.FailWithMessage(err.Error(), c)
      return
   }
   if err := iService.UpdateIndustry(i); err != nil {
   // 删除所有相关的行业
   if err := iService.DeleteAll(); err != nil {
      global.GVA_LOG.Error("更新失败!", zap.Error(err))
      response.FailWithMessage("更新失败", c)
   } else {
      response.FailWithMessage("保存失败", c)
      return
   }
   for _, industry := range i.Industries {
      if err := iService.CreateIndustry(&industry); err != nil {
         global.GVA_LOG.Error("更新失败!", zap.Error(err))
         response.FailWithMessage("保存失败", c)
      }
   }
   if err == nil {
      response.OkWithMessage("更新成功", c)
   }
}