You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

120 lines
4.7 KiB

3 years ago
  1. package autocode
  2. import (
  3. "github.com/flipped-aurora/gin-vue-admin/server/global"
  4. "github.com/flipped-aurora/gin-vue-admin/server/model/autocode"
  5. autocodeReq "github.com/flipped-aurora/gin-vue-admin/server/model/autocode/request"
  6. "github.com/flipped-aurora/gin-vue-admin/server/model/common/response"
  7. "github.com/flipped-aurora/gin-vue-admin/server/service"
  8. "github.com/flipped-aurora/gin-vue-admin/server/utils"
  9. "github.com/gin-gonic/gin"
  10. "go.uber.org/zap"
  11. )
  12. type AutoCodeExampleApi struct{}
  13. var autoCodeExampleService = service.ServiceGroupApp.AutoCodeServiceGroup.AutoCodeExampleService
  14. // @Tags AutoCodeExample
  15. // @Summary 创建AutoCodeExample
  16. // @Security ApiKeyAuth
  17. // @accept application/json
  18. // @Produce application/json
  19. // @Param data body autocode.AutoCodeExample true "AutoCodeExample模型"
  20. // @Success 200 {string} string "{"success":true,"data":{},"msg":"创建成功"}"
  21. // @Router /autoCodeExample/createAutoCodeExample [post]
  22. func (autoCodeExampleApi *AutoCodeExampleApi) CreateAutoCodeExample(c *gin.Context) {
  23. var autoCodeExample autocode.AutoCodeExample
  24. _ = c.ShouldBindJSON(&autoCodeExample)
  25. if err := autoCodeExampleService.CreateAutoCodeExample(autoCodeExample); err != nil {
  26. global.GVA_LOG.Error("创建失败!", zap.Error(err))
  27. response.FailWithMessage("创建失败", c)
  28. } else {
  29. response.OkWithMessage("创建成功", c)
  30. }
  31. }
  32. // @Tags AutoCodeExample
  33. // @Summary 删除AutoCodeExample
  34. // @Security ApiKeyAuth
  35. // @accept application/json
  36. // @Produce application/json
  37. // @Param data body autocode.AutoCodeExample true "AutoCodeExample模型"
  38. // @Success 200 {string} string "{"success":true,"data":{},"msg":"删除成功"}"
  39. // @Router /autoCodeExample/deleteAutoCodeExample [delete]
  40. func (autoCodeExampleApi *AutoCodeExampleApi) DeleteAutoCodeExample(c *gin.Context) {
  41. var autoCodeExample autocode.AutoCodeExample
  42. _ = c.ShouldBindJSON(&autoCodeExample)
  43. if err := autoCodeExampleService.DeleteAutoCodeExample(autoCodeExample); err != nil {
  44. global.GVA_LOG.Error("删除失败!", zap.Error(err))
  45. response.FailWithMessage("删除失败", c)
  46. } else {
  47. response.OkWithMessage("删除成功", c)
  48. }
  49. }
  50. // @Tags AutoCodeExample
  51. // @Summary 更新AutoCodeExample
  52. // @Security ApiKeyAuth
  53. // @accept application/json
  54. // @Produce application/json
  55. // @Param data body autocode.AutoCodeExample true "更新AutoCodeExample"
  56. // @Success 200 {string} string "{"success":true,"data":{},"msg":"更新成功"}"
  57. // @Router /autoCodeExample/updateAutoCodeExample [put]
  58. func (autoCodeExampleApi *AutoCodeExampleApi) UpdateAutoCodeExample(c *gin.Context) {
  59. var autoCodeExample autocode.AutoCodeExample
  60. _ = c.ShouldBindJSON(&autoCodeExample)
  61. if err := autoCodeExampleService.UpdateAutoCodeExample(&autoCodeExample); err != nil {
  62. global.GVA_LOG.Error("更新失败!", zap.Error(err))
  63. response.FailWithMessage("更新失败", c)
  64. } else {
  65. response.OkWithMessage("更新成功", c)
  66. }
  67. }
  68. // @Tags AutoCodeExample
  69. // @Summary 用id查询AutoCodeExample
  70. // @Security ApiKeyAuth
  71. // @accept application/json
  72. // @Produce application/json
  73. // @Param data query autocode.AutoCodeExample true "用id查询AutoCodeExample"
  74. // @Success 200 {string} string "{"success":true,"data":{},"msg":"查询成功"}"
  75. // @Router /autoCodeExample/findAutoCodeExample [get]
  76. func (autoCodeExampleApi *AutoCodeExampleApi) FindAutoCodeExample(c *gin.Context) {
  77. var autoCodeExample autocode.AutoCodeExample
  78. _ = c.ShouldBindQuery(&autoCodeExample)
  79. if err := utils.Verify(autoCodeExample, utils.IdVerify); err != nil {
  80. response.FailWithMessage(err.Error(), c)
  81. return
  82. }
  83. if err, reAutoCodeExample := autoCodeExampleService.GetAutoCodeExample(autoCodeExample.ID); err != nil {
  84. global.GVA_LOG.Error("查询失败!", zap.Error(err))
  85. response.FailWithMessage("查询失败", c)
  86. } else {
  87. response.OkWithDetailed(gin.H{"reAutoCodeExample": reAutoCodeExample}, "查询成功", c)
  88. }
  89. }
  90. // @Tags AutoCodeExample
  91. // @Summary 分页获取AutoCodeExample列表
  92. // @Security ApiKeyAuth
  93. // @accept application/json
  94. // @Produce application/json
  95. // @Param data query autocodeReq.AutoCodeExampleSearch true "页码, 每页大小, 搜索条件"
  96. // @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
  97. // @Router /autoCodeExample/getAutoCodeExampleList [get]
  98. func (autoCodeExampleApi *AutoCodeExampleApi) GetAutoCodeExampleList(c *gin.Context) {
  99. var pageInfo autocodeReq.AutoCodeExampleSearch
  100. _ = c.ShouldBindQuery(&pageInfo)
  101. if err, list, total := autoCodeExampleService.GetAutoCodeExampleInfoList(pageInfo); err != nil {
  102. global.GVA_LOG.Error("获取失败!", zap.Error(err))
  103. response.FailWithMessage("获取失败", c)
  104. } else {
  105. response.OkWithDetailed(response.PageResult{
  106. List: list,
  107. Total: total,
  108. Page: pageInfo.Page,
  109. PageSize: pageInfo.PageSize,
  110. }, "获取成功", c)
  111. }
  112. }