sys_auto_code_history.go 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. package system
  2. import (
  3. "github.com/flipped-aurora/gin-vue-admin/server/global"
  4. "github.com/flipped-aurora/gin-vue-admin/server/model/common/request"
  5. "github.com/flipped-aurora/gin-vue-admin/server/model/common/response"
  6. systemReq "github.com/flipped-aurora/gin-vue-admin/server/model/system/request"
  7. "github.com/gin-gonic/gin"
  8. "go.uber.org/zap"
  9. )
  10. type AutoCodeHistoryApi struct{}
  11. // First
  12. // @Tags AutoCode
  13. // @Summary 获取meta信息
  14. // @Security ApiKeyAuth
  15. // @accept application/json
  16. // @Produce application/json
  17. // @Param data body request.GetById true "请求参数"
  18. // @Success 200 {object} response.Response{data=map[string]interface{},msg=string} "获取meta信息"
  19. // @Router /autoCode/getMeta [post]
  20. func (a *AutoCodeHistoryApi) First(c *gin.Context) {
  21. var info request.GetById
  22. err := c.ShouldBindJSON(&info)
  23. if err != nil {
  24. response.FailWithMessage(err.Error(), c)
  25. return
  26. }
  27. data, err := autoCodeHistoryService.First(&info)
  28. if err != nil {
  29. response.FailWithMessage(err.Error(), c)
  30. return
  31. }
  32. response.OkWithDetailed(gin.H{"meta": data}, "获取成功", c)
  33. }
  34. // Delete
  35. // @Tags AutoCode
  36. // @Summary 删除回滚记录
  37. // @Security ApiKeyAuth
  38. // @accept application/json
  39. // @Produce application/json
  40. // @Param data body request.GetById true "请求参数"
  41. // @Success 200 {object} response.Response{msg=string} "删除回滚记录"
  42. // @Router /autoCode/delSysHistory [post]
  43. func (a *AutoCodeHistoryApi) Delete(c *gin.Context) {
  44. var info request.GetById
  45. err := c.ShouldBindJSON(&info)
  46. if err != nil {
  47. response.FailWithMessage(err.Error(), c)
  48. return
  49. }
  50. err = autoCodeHistoryService.Delete(&info)
  51. if err != nil {
  52. global.GVA_LOG.Error("删除失败!", zap.Error(err))
  53. response.FailWithMessage("删除失败", c)
  54. return
  55. }
  56. response.OkWithMessage("删除成功", c)
  57. }
  58. // RollBack
  59. // @Tags AutoCode
  60. // @Summary 回滚自动生成代码
  61. // @Security ApiKeyAuth
  62. // @accept application/json
  63. // @Produce application/json
  64. // @Param data body systemReq.RollBack true "请求参数"
  65. // @Success 200 {object} response.Response{msg=string} "回滚自动生成代码"
  66. // @Router /autoCode/rollback [post]
  67. func (a *AutoCodeHistoryApi) RollBack(c *gin.Context) {
  68. var info systemReq.RollBack
  69. err := c.ShouldBindJSON(&info)
  70. if err != nil {
  71. response.FailWithMessage(err.Error(), c)
  72. return
  73. }
  74. err = autoCodeHistoryService.RollBack(&info)
  75. if err != nil {
  76. response.FailWithMessage(err.Error(), c)
  77. return
  78. }
  79. response.OkWithMessage("回滚成功", c)
  80. }
  81. // GetList
  82. // @Tags AutoCode
  83. // @Summary 查询回滚记录
  84. // @Security ApiKeyAuth
  85. // @accept application/json
  86. // @Produce application/json
  87. // @Param data body systemReq.SysAutoHistory true "请求参数"
  88. // @Success 200 {object} response.Response{data=response.PageResult,msg=string} "查询回滚记录,返回包括列表,总数,页码,每页数量"
  89. // @Router /autoCode/getSysHistory [post]
  90. func (a *AutoCodeHistoryApi) GetList(c *gin.Context) {
  91. var search systemReq.SysAutoHistory
  92. err := c.ShouldBindJSON(&search)
  93. if err != nil {
  94. response.FailWithMessage(err.Error(), c)
  95. return
  96. }
  97. list, total, err := autoCodeHistoryService.GetList(search.PageInfo)
  98. if err != nil {
  99. global.GVA_LOG.Error("获取失败!", zap.Error(err))
  100. response.FailWithMessage("获取失败", c)
  101. return
  102. }
  103. response.OkWithDetailed(response.PageResult{
  104. List: list,
  105. Total: total,
  106. Page: search.Page,
  107. PageSize: search.PageSize,
  108. }, "获取成功", c)
  109. }