sys_operation_record.go 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  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. // CreateSysOperationRecord
  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/createSysOperationRecord [post]
  22. func (s *OperationRecordApi) CreateSysOperationRecord(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.CreateSysOperationRecord(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. // DeleteSysOperationRecord
  38. // @Tags SysOperationRecord
  39. // @Summary 删除SysOperationRecord
  40. // @Security ApiKeyAuth
  41. // @accept application/json
  42. // @Produce application/json
  43. // @Param data body system.SysOperationRecord true "SysOperationRecord模型"
  44. // @Success 200 {object} response.Response{msg=string} "删除SysOperationRecord"
  45. // @Router /sysOperationRecord/deleteSysOperationRecord [delete]
  46. func (s *OperationRecordApi) DeleteSysOperationRecord(c *gin.Context) {
  47. var sysOperationRecord system.SysOperationRecord
  48. err := c.ShouldBindJSON(&sysOperationRecord)
  49. if err != nil {
  50. response.FailWithMessage(err.Error(), c)
  51. return
  52. }
  53. err = operationRecordService.DeleteSysOperationRecord(sysOperationRecord)
  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. // DeleteSysOperationRecordByIds
  62. // @Tags SysOperationRecord
  63. // @Summary 批量删除SysOperationRecord
  64. // @Security ApiKeyAuth
  65. // @accept application/json
  66. // @Produce application/json
  67. // @Param data body request.IdsReq true "批量删除SysOperationRecord"
  68. // @Success 200 {object} response.Response{msg=string} "批量删除SysOperationRecord"
  69. // @Router /sysOperationRecord/deleteSysOperationRecordByIds [delete]
  70. func (s *OperationRecordApi) DeleteSysOperationRecordByIds(c *gin.Context) {
  71. var IDS request.IdsReq
  72. err := c.ShouldBindJSON(&IDS)
  73. if err != nil {
  74. response.FailWithMessage(err.Error(), c)
  75. return
  76. }
  77. err = operationRecordService.DeleteSysOperationRecordByIds(IDS)
  78. if err != nil {
  79. global.GVA_LOG.Error("批量删除失败!", zap.Error(err))
  80. response.FailWithMessage("批量删除失败", c)
  81. return
  82. }
  83. response.OkWithMessage("批量删除成功", c)
  84. }
  85. // FindSysOperationRecord
  86. // @Tags SysOperationRecord
  87. // @Summary 用id查询SysOperationRecord
  88. // @Security ApiKeyAuth
  89. // @accept application/json
  90. // @Produce application/json
  91. // @Param data query system.SysOperationRecord true "Id"
  92. // @Success 200 {object} response.Response{data=map[string]interface{},msg=string} "用id查询SysOperationRecord"
  93. // @Router /sysOperationRecord/findSysOperationRecord [get]
  94. func (s *OperationRecordApi) FindSysOperationRecord(c *gin.Context) {
  95. var sysOperationRecord system.SysOperationRecord
  96. err := c.ShouldBindQuery(&sysOperationRecord)
  97. if err != nil {
  98. response.FailWithMessage(err.Error(), c)
  99. return
  100. }
  101. err = utils.Verify(sysOperationRecord, utils.IdVerify)
  102. if err != nil {
  103. response.FailWithMessage(err.Error(), c)
  104. return
  105. }
  106. reSysOperationRecord, err := operationRecordService.GetSysOperationRecord(sysOperationRecord.ID)
  107. if err != nil {
  108. global.GVA_LOG.Error("查询失败!", zap.Error(err))
  109. response.FailWithMessage("查询失败", c)
  110. return
  111. }
  112. response.OkWithDetailed(gin.H{"reSysOperationRecord": reSysOperationRecord}, "查询成功", c)
  113. }
  114. // GetSysOperationRecordList
  115. // @Tags SysOperationRecord
  116. // @Summary 分页获取SysOperationRecord列表
  117. // @Security ApiKeyAuth
  118. // @accept application/json
  119. // @Produce application/json
  120. // @Param data query request.SysOperationRecordSearch true "页码, 每页大小, 搜索条件"
  121. // @Success 200 {object} response.Response{data=response.PageResult,msg=string} "分页获取SysOperationRecord列表,返回包括列表,总数,页码,每页数量"
  122. // @Router /sysOperationRecord/getSysOperationRecordList [get]
  123. func (s *OperationRecordApi) GetSysOperationRecordList(c *gin.Context) {
  124. var pageInfo systemReq.SysOperationRecordSearch
  125. err := c.ShouldBindQuery(&pageInfo)
  126. if err != nil {
  127. response.FailWithMessage(err.Error(), c)
  128. return
  129. }
  130. list, total, err := operationRecordService.GetSysOperationRecordInfoList(pageInfo)
  131. if err != nil {
  132. global.GVA_LOG.Error("获取失败!", zap.Error(err))
  133. response.FailWithMessage("获取失败", c)
  134. return
  135. }
  136. response.OkWithDetailed(response.PageResult{
  137. List: list,
  138. Total: total,
  139. Page: pageInfo.Page,
  140. PageSize: pageInfo.PageSize,
  141. }, "获取成功", c)
  142. }