problem_reply.go 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. package autocode
  2. import (
  3. "github.com/flipped-aurora/gin-vue-admin/server/global"
  4. "github.com/flipped-aurora/gin-vue-admin/server/model/autocode"
  5. autocodeReq "github.com/flipped-aurora/gin-vue-admin/server/model/autocode/request"
  6. "github.com/flipped-aurora/gin-vue-admin/server/model/common/request"
  7. "github.com/flipped-aurora/gin-vue-admin/server/model/common/response"
  8. "github.com/flipped-aurora/gin-vue-admin/server/service"
  9. "github.com/flipped-aurora/gin-vue-admin/server/utils"
  10. "github.com/gin-gonic/gin"
  11. "go.uber.org/zap"
  12. )
  13. type ProblemReplyApi struct {
  14. }
  15. var problemReplyService = service.ServiceGroupApp.AutoCodeServiceGroup.ProblemReplyService
  16. // CreateProblemReply 创建ProblemReply
  17. // @Tags ProblemReply
  18. // @Summary 创建ProblemReply
  19. // @Security ApiKeyAuth
  20. // @accept application/json
  21. // @Produce application/json
  22. // @Param data body autocode.ProblemReply true "创建ProblemReply"
  23. // @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
  24. // @Router /problemReply/createProblemReply [post]
  25. func (problemReplyApi *ProblemReplyApi) CreateProblemReply(c *gin.Context) {
  26. var problemReply autocode.ProblemReply
  27. _ = c.ShouldBindJSON(&problemReply)
  28. _, user := service.ServiceGroupApp.SystemServiceGroup.GetUserInfo(utils.GetUserUuid(c))
  29. problemReply.HeaderImg = user.HeaderImg
  30. problemReply.Uuid = user.UUID
  31. problemReply.NickName = user.NickName
  32. if err := problemReplyService.CreateProblemReply(problemReply); err != nil {
  33. global.GVA_LOG.Error("创建失败!", zap.Any("err", err))
  34. response.FailWithMessage("创建失败", c)
  35. } else {
  36. response.OkWithMessage("创建成功", c)
  37. }
  38. }
  39. // DeleteProblemReply 删除ProblemReply
  40. // @Tags ProblemReply
  41. // @Summary 删除ProblemReply
  42. // @Security ApiKeyAuth
  43. // @accept application/json
  44. // @Produce application/json
  45. // @Param data body autocode.ProblemReply true "删除ProblemReply"
  46. // @Success 200 {string} string "{"success":true,"data":{},"msg":"删除成功"}"
  47. // @Router /problemReply/deleteProblemReply [delete]
  48. func (problemReplyApi *ProblemReplyApi) DeleteProblemReply(c *gin.Context) {
  49. var problemReply autocode.ProblemReply
  50. _ = c.ShouldBindJSON(&problemReply)
  51. if err := problemReplyService.DeleteProblemReply(problemReply); err != nil {
  52. global.GVA_LOG.Error("删除失败!", zap.Any("err", err))
  53. response.FailWithMessage("删除失败", c)
  54. } else {
  55. response.OkWithMessage("删除成功", c)
  56. }
  57. }
  58. // DeleteProblemReplyByIds 批量删除ProblemReply
  59. // @Tags ProblemReply
  60. // @Summary 批量删除ProblemReply
  61. // @Security ApiKeyAuth
  62. // @accept application/json
  63. // @Produce application/json
  64. // @Param data body request.IdsReq true "批量删除ProblemReply"
  65. // @Success 200 {string} string "{"success":true,"data":{},"msg":"批量删除成功"}"
  66. // @Router /problemReply/deleteProblemReplyByIds [delete]
  67. func (problemReplyApi *ProblemReplyApi) DeleteProblemReplyByIds(c *gin.Context) {
  68. var IDS request.IdsReq
  69. _ = c.ShouldBindJSON(&IDS)
  70. if err := problemReplyService.DeleteProblemReplyByIds(IDS); err != nil {
  71. global.GVA_LOG.Error("批量删除失败!", zap.Any("err", err))
  72. response.FailWithMessage("批量删除失败", c)
  73. } else {
  74. response.OkWithMessage("批量删除成功", c)
  75. }
  76. }
  77. // UpdateProblemReply 更新ProblemReply
  78. // @Tags ProblemReply
  79. // @Summary 更新ProblemReply
  80. // @Security ApiKeyAuth
  81. // @accept application/json
  82. // @Produce application/json
  83. // @Param data body autocode.ProblemReply true "更新ProblemReply"
  84. // @Success 200 {string} string "{"success":true,"data":{},"msg":"更新成功"}"
  85. // @Router /problemReply/updateProblemReply [put]
  86. func (problemReplyApi *ProblemReplyApi) UpdateProblemReply(c *gin.Context) {
  87. var problemReply autocode.ProblemReply
  88. _ = c.ShouldBindJSON(&problemReply)
  89. if err := problemReplyService.UpdateProblemReply(problemReply); err != nil {
  90. global.GVA_LOG.Error("更新失败!", zap.Any("err", err))
  91. response.FailWithMessage("更新失败", c)
  92. } else {
  93. response.OkWithMessage("更新成功", c)
  94. }
  95. }
  96. // FindProblemReply 用id查询ProblemReply
  97. // @Tags ProblemReply
  98. // @Summary 用id查询ProblemReply
  99. // @Security ApiKeyAuth
  100. // @accept application/json
  101. // @Produce application/json
  102. // @Param data query autocode.ProblemReply true "用id查询ProblemReply"
  103. // @Success 200 {string} string "{"success":true,"data":{},"msg":"查询成功"}"
  104. // @Router /problemReply/findProblemReply [get]
  105. func (problemReplyApi *ProblemReplyApi) FindProblemReply(c *gin.Context) {
  106. var problemReply autocode.ProblemReply
  107. _ = c.ShouldBindQuery(&problemReply)
  108. if err, reproblemReply := problemReplyService.GetProblemReply(problemReply.ID); err != nil {
  109. global.GVA_LOG.Error("查询失败!", zap.Any("err", err))
  110. response.FailWithMessage("查询失败", c)
  111. } else {
  112. response.OkWithData(gin.H{"reproblemReply": reproblemReply}, c)
  113. }
  114. }
  115. // GetProblemReplyList 分页获取ProblemReply列表
  116. // @Tags ProblemReply
  117. // @Summary 分页获取ProblemReply列表
  118. // @Security ApiKeyAuth
  119. // @accept application/json
  120. // @Produce application/json
  121. // @Param data query autocodeReq.ProblemReplySearch true "分页获取ProblemReply列表"
  122. // @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
  123. // @Router /problemReply/getProblemReplyList [get]
  124. func (problemReplyApi *ProblemReplyApi) GetProblemReplyList(c *gin.Context) {
  125. var pageInfo autocodeReq.ProblemReplySearch
  126. _ = c.ShouldBindQuery(&pageInfo)
  127. if err, list, total := problemReplyService.GetProblemReplyInfoList(pageInfo); err != nil {
  128. global.GVA_LOG.Error("获取失败!", zap.Any("err", err))
  129. response.FailWithMessage("获取失败", c)
  130. } else {
  131. response.OkWithDetailed(response.PageResult{
  132. List: list,
  133. Total: total,
  134. Page: pageInfo.Page,
  135. PageSize: pageInfo.PageSize,
  136. }, "获取成功", c)
  137. }
  138. }