From c2e727dcdfa8970f629c3e3884bd866398bf3f48 Mon Sep 17 00:00:00 2001 From: wangpengfei <274878379@qq.com> Date: 星期五, 25 八月 2023 16:31:30 +0800 Subject: [PATCH] fix --- api/v1/test/industry.go | 22 +++++++++++++++++----- 1 files changed, 17 insertions(+), 5 deletions(-) diff --git a/api/v1/test/industry.go b/api/v1/test/industry.go index 6ff455e..871e889 100644 --- a/api/v1/test/industry.go +++ b/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) } } -- Gitblit v1.8.0