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 | 48 +++++++++++++++++++++++++++++------------------- 1 files changed, 29 insertions(+), 19 deletions(-) diff --git a/api/v1/test/supplier_type.go b/api/v1/test/supplier_type.go index 7d479b1..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 { @@ -24,7 +24,7 @@ // @Produce application/json // @Param data body test.SupplierType true "鍒涘缓SupplierType" // @Success 200 {string} string "{"success":true,"data":{},"msg":"鑾峰彇鎴愬姛"}" -// @Router /api/st/createSupplierType [post] +// @Router /st/createSupplierType [post] func (stApi *SupplierTypeApi) CreateSupplierType(c *gin.Context) { var st test.SupplierType err := c.ShouldBindJSON(&st) @@ -48,7 +48,7 @@ // @Produce application/json // @Param data body test.SupplierType true "鍒犻櫎SupplierType" // @Success 200 {string} string "{"success":true,"data":{},"msg":"鍒犻櫎鎴愬姛"}" -// @Router /api/st/deleteSupplierType [delete] +// @Router /st/deleteSupplierType [delete] func (stApi *SupplierTypeApi) DeleteSupplierType(c *gin.Context) { var st test.SupplierType err := c.ShouldBindJSON(&st) @@ -72,7 +72,7 @@ // @Produce application/json // @Param data body request.IdsReq true "鎵归噺鍒犻櫎SupplierType" // @Success 200 {string} string "{"success":true,"data":{},"msg":"鎵归噺鍒犻櫎鎴愬姛"}" -// @Router /api/st/deleteSupplierTypeByIds [delete] +// @Router /st/deleteSupplierTypeByIds [delete] func (stApi *SupplierTypeApi) DeleteSupplierTypeByIds(c *gin.Context) { var IDS request.IdsReq err := c.ShouldBindJSON(&IDS) @@ -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 /api/st/updateSupplierType [put] +// @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 @@ -120,7 +130,7 @@ // @Produce application/json // @Param data query test.SupplierType true "鐢╥d鏌ヨSupplierType" // @Success 200 {string} string "{"success":true,"data":{},"msg":"鏌ヨ鎴愬姛"}" -// @Router /api/st/findSupplierType [get] +// @Router /st/findSupplierType [get] func (stApi *SupplierTypeApi) FindSupplierType(c *gin.Context) { var st test.SupplierType err := c.ShouldBindQuery(&st) @@ -144,7 +154,7 @@ // @Produce application/json // @Param data query testReq.SupplierTypeSearch true "鍒嗛〉鑾峰彇SupplierType鍒楄〃" // @Success 200 {string} string "{"success":true,"data":{},"msg":"鑾峰彇鎴愬姛"}" -// @Router /api/st/getSupplierTypeList [get] +// @Router /st/getSupplierTypeList [get] func (stApi *SupplierTypeApi) GetSupplierTypeList(c *gin.Context) { var pageInfo testReq.SupplierTypeSearch err := c.ShouldBindQuery(&pageInfo) -- Gitblit v1.8.0