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.

130 lines
4.6 KiB

  1. package v1
  2. import (
  3. "fmt"
  4. "gin-vue-admin/global/response"
  5. "gin-vue-admin/model"
  6. "gin-vue-admin/model/request"
  7. resp "gin-vue-admin/model/response"
  8. "gin-vue-admin/service"
  9. "github.com/gin-gonic/gin"
  10. )
  11. // @Tags SysOperationRecord
  12. // @Summary 创建SysOperationRecord
  13. // @Security ApiKeyAuth
  14. // @accept application/json
  15. // @Produce application/json
  16. // @Param data body model.SysOperationRecord true "创建SysOperationRecord"
  17. // @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
  18. // @Router /sysOperationRecord/createSysOperationRecord [post]
  19. func CreateSysOperationRecord(c *gin.Context) {
  20. var sysOperationRecord model.SysOperationRecord
  21. _ = c.ShouldBindJSON(&sysOperationRecord)
  22. err := service.CreateSysOperationRecord(sysOperationRecord)
  23. if err != nil {
  24. response.FailWithMessage(fmt.Sprintf("创建失败,%v", err), c)
  25. } else {
  26. response.OkWithMessage("创建成功", c)
  27. }
  28. }
  29. // @Tags SysOperationRecord
  30. // @Summary 删除SysOperationRecord
  31. // @Security ApiKeyAuth
  32. // @accept application/json
  33. // @Produce application/json
  34. // @Param data body model.SysOperationRecord true "删除SysOperationRecord"
  35. // @Success 200 {string} string "{"success":true,"data":{},"msg":"删除成功"}"
  36. // @Router /sysOperationRecord/deleteSysOperationRecord [delete]
  37. func DeleteSysOperationRecord(c *gin.Context) {
  38. var sysOperationRecord model.SysOperationRecord
  39. _ = c.ShouldBindJSON(&sysOperationRecord)
  40. err := service.DeleteSysOperationRecord(sysOperationRecord)
  41. if err != nil {
  42. response.FailWithMessage(fmt.Sprintf("删除失败,%v", err), c)
  43. } else {
  44. response.OkWithMessage("删除成功", c)
  45. }
  46. }
  47. // @Tags SysOperationRecord
  48. // @Summary 批量删除SysOperationRecord
  49. // @Security ApiKeyAuth
  50. // @accept application/json
  51. // @Produce application/json
  52. // @Param data body request.IdsReq true "批量删除SysOperationRecord"
  53. // @Success 200 {string} string "{"success":true,"data":{},"msg":"删除成功"}"
  54. // @Router /sysOperationRecord/deleteSysOperationRecordByIds [delete]
  55. func DeleteSysOperationRecordByIds(c *gin.Context) {
  56. var IDS request.IdsReq
  57. _ = c.ShouldBindJSON(&IDS)
  58. err := service.DeleteSysOperationRecordByIds(IDS)
  59. if err != nil {
  60. response.FailWithMessage(fmt.Sprintf("删除失败,%v", err), c)
  61. } else {
  62. response.OkWithMessage("删除成功", c)
  63. }
  64. }
  65. // @Tags SysOperationRecord
  66. // @Summary 更新SysOperationRecord
  67. // @Security ApiKeyAuth
  68. // @accept application/json
  69. // @Produce application/json
  70. // @Param data body model.SysOperationRecord true "更新SysOperationRecord"
  71. // @Success 200 {string} string "{"success":true,"data":{},"msg":"更新成功"}"
  72. // @Router /sysOperationRecord/updateSysOperationRecord [put]
  73. func UpdateSysOperationRecord(c *gin.Context) {
  74. var sysOperationRecord model.SysOperationRecord
  75. _ = c.ShouldBindJSON(&sysOperationRecord)
  76. err := service.UpdateSysOperationRecord(&sysOperationRecord)
  77. if err != nil {
  78. response.FailWithMessage(fmt.Sprintf("更新失败,%v", err), c)
  79. } else {
  80. response.OkWithMessage("更新成功", c)
  81. }
  82. }
  83. // @Tags SysOperationRecord
  84. // @Summary 用id查询SysOperationRecord
  85. // @Security ApiKeyAuth
  86. // @accept application/json
  87. // @Produce application/json
  88. // @Param data body model.SysOperationRecord true "用id查询SysOperationRecord"
  89. // @Success 200 {string} string "{"success":true,"data":{},"msg":"查询成功"}"
  90. // @Router /sysOperationRecord/findSysOperationRecord [get]
  91. func FindSysOperationRecord(c *gin.Context) {
  92. var sysOperationRecord model.SysOperationRecord
  93. _ = c.ShouldBindQuery(&sysOperationRecord)
  94. err, resysOperationRecord := service.GetSysOperationRecord(sysOperationRecord.ID)
  95. if err != nil {
  96. response.FailWithMessage(fmt.Sprintf("查询失败,%v", err), c)
  97. } else {
  98. response.OkWithData(gin.H{"resysOperationRecord": resysOperationRecord}, c)
  99. }
  100. }
  101. // @Tags SysOperationRecord
  102. // @Summary 分页获取SysOperationRecord列表
  103. // @Security ApiKeyAuth
  104. // @accept application/json
  105. // @Produce application/json
  106. // @Param data body request.SysOperationRecordSearch true "分页获取SysOperationRecord列表"
  107. // @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
  108. // @Router /sysOperationRecord/getSysOperationRecordList [get]
  109. func GetSysOperationRecordList(c *gin.Context) {
  110. var pageInfo request.SysOperationRecordSearch
  111. _ = c.ShouldBindQuery(&pageInfo)
  112. err, list, total := service.GetSysOperationRecordInfoList(pageInfo)
  113. if err != nil {
  114. response.FailWithMessage(fmt.Sprintf("获取数据失败,%v", err), c)
  115. } else {
  116. response.OkWithData(resp.PageResult{
  117. List: list,
  118. Total: total,
  119. Page: pageInfo.Page,
  120. PageSize: pageInfo.PageSize,
  121. }, c)
  122. }
  123. }