| | |
| | | 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 { |
| | |
| | | // @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) |
| | |
| | | // @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) |
| | |
| | | // @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) |
| | |
| | | // @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 |
| | |
| | | // @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) |
| | |
| | | // @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) |