sys_operation_record.go 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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. }
  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 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
  21. // @Router /sysOperationRecord/createSysOperationRecord [post]
  22. func (s *OperationRecordApi) CreateSysOperationRecord(c *gin.Context) {
  23. var sysOperationRecord system.SysOperationRecord
  24. _ = c.ShouldBindJSON(&sysOperationRecord)
  25. if err := operationRecordService.CreateSysOperationRecord(sysOperationRecord); err != nil {
  26. global.GVA_LOG.Error("创建失败!", zap.Any("err", err))
  27. response.FailWithMessage("创建失败", c)
  28. } else {
  29. response.OkWithMessage("创建成功", c)
  30. }
  31. }
  32. // @Tags SysOperationRecord
  33. // @Summary 删除SysOperationRecord
  34. // @Security ApiKeyAuth
  35. // @accept application/json
  36. // @Produce application/json
  37. // @Param data body system.SysOperationRecord true "SysOperationRecord模型"
  38. // @Success 200 {string} string "{"success":true,"data":{},"msg":"删除成功"}"
  39. // @Router /sysOperationRecord/deleteSysOperationRecord [delete]
  40. func (s *OperationRecordApi) DeleteSysOperationRecord(c *gin.Context) {
  41. var sysOperationRecord system.SysOperationRecord
  42. _ = c.ShouldBindJSON(&sysOperationRecord)
  43. if err := operationRecordService.DeleteSysOperationRecord(sysOperationRecord); err != nil {
  44. global.GVA_LOG.Error("删除失败!", zap.Any("err", err))
  45. response.FailWithMessage("删除失败", c)
  46. } else {
  47. response.OkWithMessage("删除成功", c)
  48. }
  49. }
  50. // @Tags SysOperationRecord
  51. // @Summary 批量删除SysOperationRecord
  52. // @Security ApiKeyAuth
  53. // @accept application/json
  54. // @Produce application/json
  55. // @Param data body request.IdsReq true "批量删除SysOperationRecord"
  56. // @Success 200 {string} string "{"success":true,"data":{},"msg":"批量删除成功"}"
  57. // @Router /sysOperationRecord/deleteSysOperationRecordByIds [delete]
  58. func (s *OperationRecordApi) DeleteSysOperationRecordByIds(c *gin.Context) {
  59. var IDS request.IdsReq
  60. _ = c.ShouldBindJSON(&IDS)
  61. if err := operationRecordService.DeleteSysOperationRecordByIds(IDS); err != nil {
  62. global.GVA_LOG.Error("批量删除失败!", zap.Any("err", err))
  63. response.FailWithMessage("批量删除失败", c)
  64. } else {
  65. response.OkWithMessage("批量删除成功", c)
  66. }
  67. }
  68. // @Tags SysOperationRecord
  69. // @Summary 用id查询SysOperationRecord
  70. // @Security ApiKeyAuth
  71. // @accept application/json
  72. // @Produce application/json
  73. // @Param data query system.SysOperationRecord true "Id"
  74. // @Success 200 {string} string "{"success":true,"data":{},"msg":"查询成功"}"
  75. // @Router /sysOperationRecord/findSysOperationRecord [get]
  76. func (s *OperationRecordApi) FindSysOperationRecord(c *gin.Context) {
  77. var sysOperationRecord system.SysOperationRecord
  78. _ = c.ShouldBindQuery(&sysOperationRecord)
  79. if err := utils.Verify(sysOperationRecord, utils.IdVerify); err != nil {
  80. response.FailWithMessage(err.Error(), c)
  81. return
  82. }
  83. if err, resysOperationRecord := operationRecordService.GetSysOperationRecord(sysOperationRecord.ID); err != nil {
  84. global.GVA_LOG.Error("查询失败!", zap.Any("err", err))
  85. response.FailWithMessage("查询失败", c)
  86. } else {
  87. response.OkWithDetailed(gin.H{"resysOperationRecord": resysOperationRecord}, "查询成功", c)
  88. }
  89. }
  90. // @Tags SysOperationRecord
  91. // @Summary 分页获取SysOperationRecord列表
  92. // @Security ApiKeyAuth
  93. // @accept application/json
  94. // @Produce application/json
  95. // @Param data query request.SysOperationRecordSearch true "页码, 每页大小, 搜索条件"
  96. // @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
  97. // @Router /sysOperationRecord/getSysOperationRecordList [get]
  98. func (s *OperationRecordApi) GetSysOperationRecordList(c *gin.Context) {
  99. var pageInfo systemReq.SysOperationRecordSearch
  100. _ = c.ShouldBindQuery(&pageInfo)
  101. if err, list, total := operationRecordService.GetSysOperationRecordInfoList(pageInfo); err != nil {
  102. global.GVA_LOG.Error("获取失败!", zap.Any("err", err))
  103. response.FailWithMessage("获取失败", c)
  104. } else {
  105. response.OkWithDetailed(response.PageResult{
  106. List: list,
  107. Total: total,
  108. Page: pageInfo.Page,
  109. PageSize: pageInfo.PageSize,
  110. }, "获取成功", c)
  111. }
  112. }