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 Applicationv0.0.0 // @Summary 创建Application // @Security ApiKeyAuth // @accept application/json // @Produce application/json // @Param data body model.Application true "创建Application" // @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}" // @Router /application/createApplication [post] func CreateApplication(c *gin.Context) { var application model.Application _ = c.ShouldBindJSON(&application) if err := service.CreateApplication(application); err != nil { global.MG_LOG.Error("创建失败!", zap.Any("err", err)) response.FailWithMessage("创建失败", c) } else { response.OkWithMessage("创建成功", c) } } // @Tags Applicationv0.0.0 // @Summary 删除Application // @Security ApiKeyAuth // @accept application/json // @Produce application/json // @Param data body model.Application true "删除Application" // @Success 200 {string} string "{"success":true,"data":{},"msg":"删除成功"}" // @Router /application/deleteApplication [delete] func DeleteApplication(c *gin.Context) { var application model.Application _ = c.ShouldBindJSON(&application) if err := service.DeleteApplication(application); err != nil { global.MG_LOG.Error("删除失败!", zap.Any("err", err)) response.FailWithMessage("删除失败", c) } else { response.OkWithMessage("删除成功", c) } } // @Tags Applicationv0.0.0 // @Summary 批量删除Application // @Security ApiKeyAuth // @accept application/json // @Produce application/json // @Param data body request.IdsReq true "批量删除Application" // @Success 200 {string} string "{"success":true,"data":{},"msg":"批量删除成功"}" // @Router /application/deleteApplicationByIds [delete] func DeleteApplicationByIds(c *gin.Context) { var IDS request.IdsReq _ = c.ShouldBindJSON(&IDS) if err := service.DeleteApplicationByIds(IDS); err != nil { global.MG_LOG.Error("批量删除失败!", zap.Any("err", err)) response.FailWithMessage("批量删除失败", c) } else { response.OkWithMessage("批量删除成功", c) } } // @Tags Applicationv0.0.0 // @Summary 更新Application // @Security ApiKeyAuth // @accept application/json // @Produce application/json // @Param data body model.Application true "更新Application" // @Success 200 {string} string "{"success":true,"data":{},"msg":"更新成功"}" // @Router /application/updateApplication [put] func UpdateApplication(c *gin.Context) { var application model.Application _ = c.ShouldBindJSON(&application) if err := service.UpdateApplication(application); err != nil { global.MG_LOG.Error("更新失败!", zap.Any("err", err)) response.FailWithMessage("更新失败", c) } else { response.OkWithMessage("更新成功", c) } } // @Tags Applicationv0.0.0 // @Summary 用id查询Application // @Security ApiKeyAuth // @accept application/json // @Produce application/json // @Param data body model.Application true "用id查询Application" // @Success 200 {string} string "{"success":true,"data":{},"msg":"查询成功"}" // @Router /application/findApplication [get] func FindApplication(c *gin.Context) { var application model.Application _ = c.ShouldBindQuery(&application) if err, reapplication := service.GetApplication(application.ID); err != nil { global.MG_LOG.Error("查询失败!", zap.Any("err", err)) response.FailWithMessage("查询失败", c) } else { response.OkWithData(gin.H{"reapplication": reapplication}, c) } } // @Tags Applicationv0.0.0 // @Summary 分页获取Application列表 // @Security ApiKeyAuth // @accept application/json // @Produce application/json // @Param data body request.ApplicationSearch true "分页获取Application列表" // @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}" // @Router /application/getApplicationList [get] func GetApplicationList(c *gin.Context) { var pageInfo request.ApplicationSearch _ = c.ShouldBindQuery(&pageInfo) if err, list, total := service.GetApplicationInfoList(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) } }