From d20acf38c36c11ee4428c3e74a17f5870dc61b51 Mon Sep 17 00:00:00 2001 From: liujiandao <274878379@qq.com> Date: 星期四, 16 十一月 2023 09:51:00 +0800 Subject: [PATCH] Merge branch 'master' of http://192.168.5.5:10010/r/aps/SRM --- api/v1/test/supplier_type.go | 36 +++++++++++++++++++++++------------- 1 files changed, 23 insertions(+), 13 deletions(-) diff --git a/api/v1/test/supplier_type.go b/api/v1/test/supplier_type.go index 9cd5b4d..7b1a490 100644 --- a/api/v1/test/supplier_type.go +++ b/api/v1/test/supplier_type.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 SupplierTypeApi struct { @@ -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 鐢╥d鏌ヨSupplierType -- Gitblit v1.8.0