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.

98 lines
2.9 KiB

  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{} "获取成功!"
  19. // @Router /autoCode/getMeta [post]
  20. func (a *AutoCodeHistoryApi) First(c *gin.Context) {
  21. var info request.GetById
  22. _ = c.ShouldBindJSON(&info)
  23. data, err := autoCodeHistoryService.First(&info)
  24. if err != nil {
  25. response.FailWithMessage(err.Error(), c)
  26. return
  27. }
  28. response.OkWithDetailed(gin.H{"meta": data}, "获取成功", c)
  29. }
  30. // Delete
  31. // @Tags AutoCode
  32. // @Summary 删除回滚记录
  33. // @Security ApiKeyAuth
  34. // @accept application/json
  35. // @Produce application/json
  36. // @Param data body request.GetById true "请求参数"
  37. // @Success 200 {object} response.Response{} "删除成功!"
  38. // @Router /autoCode/delSysHistory [post]
  39. func (a *AutoCodeHistoryApi) Delete(c *gin.Context) {
  40. var info request.GetById
  41. _ = c.ShouldBindJSON(&info)
  42. err := autoCodeHistoryService.Delete(&info)
  43. if err != nil {
  44. global.GVA_LOG.Error("删除失败!", zap.Error(err))
  45. response.FailWithMessage("删除失败", c)
  46. return
  47. }
  48. response.OkWithMessage("删除成功", c)
  49. }
  50. // RollBack
  51. // @Tags AutoCode
  52. // @Summary 回滚自动生成代码
  53. // @Security ApiKeyAuth
  54. // @accept application/json
  55. // @Produce application/json
  56. // @Param data body request.GetById true "请求参数"
  57. // @Success 200 {object} response.Response{} "回滚成功!"
  58. // @Router /autoCode/rollback [post]
  59. func (a *AutoCodeHistoryApi) RollBack(c *gin.Context) {
  60. var info request.GetById
  61. _ = c.ShouldBindJSON(&info)
  62. if err := autoCodeHistoryService.RollBack(&info); err != nil {
  63. response.FailWithMessage(err.Error(), c)
  64. return
  65. }
  66. response.OkWithMessage("回滚成功", c)
  67. }
  68. // GetList
  69. // @Tags AutoCode
  70. // @Summary 查询回滚记录
  71. // @Security ApiKeyAuth
  72. // @accept application/json
  73. // @Produce application/json
  74. // @Param data body systemReq.SysAutoHistory true "请求参数"
  75. // @Success 200 {object} response.Response{} "获取成功!"
  76. // @Router /autoCode/getSysHistory [post]
  77. func (a *AutoCodeHistoryApi) GetList(c *gin.Context) {
  78. var search systemReq.SysAutoHistory
  79. _ = c.ShouldBindJSON(&search)
  80. list, total, err := autoCodeHistoryService.GetList(search.PageInfo)
  81. if err != nil {
  82. global.GVA_LOG.Error("获取失败!", zap.Error(err))
  83. response.FailWithMessage("获取失败", c)
  84. return
  85. }
  86. response.OkWithDetailed(response.PageResult{
  87. List: list,
  88. Total: total,
  89. Page: search.Page,
  90. PageSize: search.PageSize,
  91. }, "获取成功", c)
  92. }