sys_operation_record.go 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  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. "github.com/flipped-aurora/gin-vue-admin/server/model/system"
  7. systemReq "github.com/flipped-aurora/gin-vue-admin/server/model/system/request"
  8. "github.com/flipped-aurora/gin-vue-admin/server/utils"
  9. "github.com/gin-gonic/gin"
  10. "go.uber.org/zap"
  11. )
  12. type OperationRecordApi struct{}
  13. // DeleteSysOperationRecord
  14. // @Tags SysOperationRecord
  15. // @Summary 删除SysOperationRecord
  16. // @Security ApiKeyAuth
  17. // @accept application/json
  18. // @Produce application/json
  19. // @Param data body system.SysOperationRecord true "SysOperationRecord模型"
  20. // @Success 200 {object} response.Response{msg=string} "删除SysOperationRecord"
  21. // @Router /sysOperationRecord/deleteSysOperationRecord [delete]
  22. func (s *OperationRecordApi) DeleteSysOperationRecord(c *gin.Context) {
  23. var sysOperationRecord system.SysOperationRecord
  24. err := c.ShouldBindJSON(&sysOperationRecord)
  25. if err != nil {
  26. response.FailWithMessage(err.Error(), c)
  27. return
  28. }
  29. err = operationRecordService.DeleteSysOperationRecord(sysOperationRecord)
  30. if err != nil {
  31. global.GVA_LOG.Error("删除失败!", zap.Error(err))
  32. response.FailWithMessage("删除失败", c)
  33. return
  34. }
  35. response.OkWithMessage("删除成功", c)
  36. }
  37. // DeleteSysOperationRecordByIds
  38. // @Tags SysOperationRecord
  39. // @Summary 批量删除SysOperationRecord
  40. // @Security ApiKeyAuth
  41. // @accept application/json
  42. // @Produce application/json
  43. // @Param data body request.IdsReq true "批量删除SysOperationRecord"
  44. // @Success 200 {object} response.Response{msg=string} "批量删除SysOperationRecord"
  45. // @Router /sysOperationRecord/deleteSysOperationRecordByIds [delete]
  46. func (s *OperationRecordApi) DeleteSysOperationRecordByIds(c *gin.Context) {
  47. var IDS request.IdsReq
  48. err := c.ShouldBindJSON(&IDS)
  49. if err != nil {
  50. response.FailWithMessage(err.Error(), c)
  51. return
  52. }
  53. err = operationRecordService.DeleteSysOperationRecordByIds(IDS)
  54. if err != nil {
  55. global.GVA_LOG.Error("批量删除失败!", zap.Error(err))
  56. response.FailWithMessage("批量删除失败", c)
  57. return
  58. }
  59. response.OkWithMessage("批量删除成功", c)
  60. }
  61. // FindSysOperationRecord
  62. // @Tags SysOperationRecord
  63. // @Summary 用id查询SysOperationRecord
  64. // @Security ApiKeyAuth
  65. // @accept application/json
  66. // @Produce application/json
  67. // @Param data query system.SysOperationRecord true "Id"
  68. // @Success 200 {object} response.Response{data=map[string]interface{},msg=string} "用id查询SysOperationRecord"
  69. // @Router /sysOperationRecord/findSysOperationRecord [get]
  70. func (s *OperationRecordApi) FindSysOperationRecord(c *gin.Context) {
  71. var sysOperationRecord system.SysOperationRecord
  72. err := c.ShouldBindQuery(&sysOperationRecord)
  73. if err != nil {
  74. response.FailWithMessage(err.Error(), c)
  75. return
  76. }
  77. err = utils.Verify(sysOperationRecord, utils.IdVerify)
  78. if err != nil {
  79. response.FailWithMessage(err.Error(), c)
  80. return
  81. }
  82. reSysOperationRecord, err := operationRecordService.GetSysOperationRecord(sysOperationRecord.ID)
  83. if err != nil {
  84. global.GVA_LOG.Error("查询失败!", zap.Error(err))
  85. response.FailWithMessage("查询失败", c)
  86. return
  87. }
  88. response.OkWithDetailed(gin.H{"reSysOperationRecord": reSysOperationRecord}, "查询成功", c)
  89. }
  90. // GetSysOperationRecordList
  91. // @Tags SysOperationRecord
  92. // @Summary 分页获取SysOperationRecord列表
  93. // @Security ApiKeyAuth
  94. // @accept application/json
  95. // @Produce application/json
  96. // @Param data query request.SysOperationRecordSearch true "页码, 每页大小, 搜索条件"
  97. // @Success 200 {object} response.Response{data=response.PageResult,msg=string} "分页获取SysOperationRecord列表,返回包括列表,总数,页码,每页数量"
  98. // @Router /sysOperationRecord/getSysOperationRecordList [get]
  99. func (s *OperationRecordApi) GetSysOperationRecordList(c *gin.Context) {
  100. var pageInfo systemReq.SysOperationRecordSearch
  101. err := c.ShouldBindQuery(&pageInfo)
  102. if err != nil {
  103. response.FailWithMessage(err.Error(), c)
  104. return
  105. }
  106. list, total, err := operationRecordService.GetSysOperationRecordInfoList(pageInfo)
  107. if err != nil {
  108. global.GVA_LOG.Error("获取失败!", zap.Error(err))
  109. response.FailWithMessage("获取失败", c)
  110. return
  111. }
  112. response.OkWithDetailed(response.PageResult{
  113. List: list,
  114. Total: total,
  115. Page: pageInfo.Page,
  116. PageSize: pageInfo.PageSize,
  117. }, "获取成功", c)
  118. }