zhangqian
2023-08-26 5193dcb9336e853502baf8a539d3f45efebe2f86
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 用id查询SupplierType
@@ -120,7 +130,7 @@
// @Produce application/json
// @Param data query test.SupplierType true "用id查询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)