sys_operation_record.go 4.6 KB

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