From 8c986e1342a2efde9d05dee5df0f9299ba10c139 Mon Sep 17 00:00:00 2001
From: wangpengfei <274878379@qq.com>
Date: 星期六, 26 八月 2023 17:14:08 +0800
Subject: [PATCH] add
---
api/v1/test/industry.go | 35 +++++++++++++++++++++++------------
1 files changed, 23 insertions(+), 12 deletions(-)
diff --git a/api/v1/test/industry.go b/api/v1/test/industry.go
index 6ff455e..47caef3 100644
--- a/api/v1/test/industry.go
+++ b/api/v1/test/industry.go
@@ -1,14 +1,14 @@
package test
import (
- "github.com/flipped-aurora/gin-vue-admin/server/global"
- "github.com/flipped-aurora/gin-vue-admin/server/model/common/request"
- "github.com/flipped-aurora/gin-vue-admin/server/model/common/response"
- "github.com/flipped-aurora/gin-vue-admin/server/model/test"
- testReq "github.com/flipped-aurora/gin-vue-admin/server/model/test/request"
- "github.com/flipped-aurora/gin-vue-admin/server/service"
"github.com/gin-gonic/gin"
"go.uber.org/zap"
+ "srm/global"
+ "srm/model/common/request"
+ "srm/model/common/response"
+ "srm/model/test"
+ testReq "srm/model/test/request"
+ "srm/service"
)
type IndustryApi struct {
@@ -94,22 +94,33 @@
// @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.OkWithMessage("鏇存柊鎴愬姛", c)
+ 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)
+ return
+ }
+ }
+
+ response.OkWithMessage("鏇存柊鎴愬姛", c)
}
// FindIndustry 鐢╥d鏌ヨIndustry
--
Gitblit v1.8.0