package v1 import ( "pure-admin/global" "pure-admin/model" "pure-admin/model/request" "pure-admin/model/response" "pure-admin/service" "github.com/gin-gonic/gin" "go.uber.org/zap" ) // @Tags Providerv0.0.0 // @Summary 创建Provider // @Security ApiKeyAuth // @accept application/json // @Produce application/json // @Param data body model.Provider true "创建Provider" // @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}" // @Router /provider/createProvider [post] func CreateProvider(c *gin.Context) { var provider model.Provider _ = c.ShouldBindJSON(&provider) if err := service.CreateProvider(provider); err != nil { global.MG_LOG.Error("创建失败!", zap.Any("err", err)) response.FailWithMessage("创建失败", c) } else { response.OkWithMessage("创建成功", c) } } // @Tags Providerv0.0.0 // @Summary 删除Provider // @Security ApiKeyAuth // @accept application/json // @Produce application/json // @Param data body model.Provider true "删除Provider" // @Success 200 {string} string "{"success":true,"data":{},"msg":"删除成功"}" // @Router /provider/deleteProvider [delete] func DeleteProvider(c *gin.Context) { var provider model.Provider _ = c.ShouldBindJSON(&provider) if err := service.DeleteProvider(provider); err != nil { global.MG_LOG.Error("删除失败!", zap.Any("err", err)) response.FailWithMessage("删除失败", c) } else { response.OkWithMessage("删除成功", c) } } // @Tags Providerv0.0.0 // @Summary 批量删除Provider // @Security ApiKeyAuth // @accept application/json // @Produce application/json // @Param data body request.IdsReq true "批量删除Provider" // @Success 200 {string} string "{"success":true,"data":{},"msg":"批量删除成功"}" // @Router /provider/deleteProviderByIds [delete] func DeleteProviderByIds(c *gin.Context) { var IDS request.IdsReq _ = c.ShouldBindJSON(&IDS) if err := service.DeleteProviderByIds(IDS); err != nil { global.MG_LOG.Error("批量删除失败!", zap.Any("err", err)) response.FailWithMessage("批量删除失败", c) } else { response.OkWithMessage("批量删除成功", c) } } // @Tags Providerv0.0.0 // @Summary 更新Provider // @Security ApiKeyAuth // @accept application/json // @Produce application/json // @Param data body model.Provider true "更新Provider" // @Success 200 {string} string "{"success":true,"data":{},"msg":"更新成功"}" // @Router /provider/updateProvider [put] func UpdateProvider(c *gin.Context) { var provider model.Provider _ = c.ShouldBindJSON(&provider) if err := service.UpdateProvider(provider); err != nil { global.MG_LOG.Error("更新失败!", zap.Any("err", err)) response.FailWithMessage("更新失败", c) } else { response.OkWithMessage("更新成功", c) } } // @Tags Providerv0.0.0 // @Summary 用id查询Provider // @Security ApiKeyAuth // @accept application/json // @Produce application/json // @Param data body model.Provider true "用id查询Provider" // @Success 200 {string} string "{"success":true,"data":{},"msg":"查询成功"}" // @Router /provider/findProvider [get] func FindProvider(c *gin.Context) { var provider model.Provider _ = c.ShouldBindQuery(&provider) if err, reprovider := service.GetProvider(provider.ID); err != nil { global.MG_LOG.Error("查询失败!", zap.Any("err", err)) response.FailWithMessage("查询失败", c) } else { response.OkWithData(gin.H{"reprovider": reprovider}, c) } } // @Tags Providerv0.0.0 // @Summary 分页获取Provider列表 // @Security ApiKeyAuth // @accept application/json // @Produce application/json // @Param data body request.ProviderSearch true "分页获取Provider列表" // @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}" // @Router /provider/getProviderList [get] func GetProviderList(c *gin.Context) { var pageInfo request.ProviderSearch _ = c.ShouldBindQuery(&pageInfo) if err, list, total := service.GetProviderInfoList(pageInfo); err != nil { global.MG_LOG.Error("获取失败!", zap.Any("err", err)) response.FailWithMessage("获取失败", c) } else { response.OkWithDetailed(response.PageResult{ List: list, Total: total, Page: pageInfo.Page, PageSize: pageInfo.PageSize, }, "获取成功", c) } }