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.

121 lines
4.7 KiB

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