FeedbackMsgController.java 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. package com.chuanghai.smartschool.tuitionpayment.controller;
  2. import com.alibaba.fastjson.JSONObject;
  3. import com.chuanghai.smartschool.tuitionpayment.anno.AdminLoginCheck;
  4. import com.chuanghai.smartschool.tuitionpayment.common.exception.BizCodeEnume;
  5. import com.chuanghai.smartschool.tuitionpayment.common.exception.RRException;
  6. import com.chuanghai.smartschool.tuitionpayment.common.utils.CommonResult;
  7. import com.chuanghai.smartschool.tuitionpayment.common.utils.PageParam;
  8. import com.chuanghai.smartschool.tuitionpayment.common.utils.PageUtils;
  9. import com.chuanghai.smartschool.tuitionpayment.entity.FeedbackMsgEntity;
  10. import com.chuanghai.smartschool.tuitionpayment.service.FeedbackMsgService;
  11. import com.chuanghai.smartschool.tuitionpayment.to.FeedbackMsgCreateTO;
  12. import com.chuanghai.smartschool.tuitionpayment.to.PayOrderQueryTO;
  13. import com.chuanghai.smartschool.tuitionpayment.vo.FeedbackMsgQueryVO;
  14. import org.apache.poi.ss.formula.functions.T;
  15. import org.springframework.beans.factory.annotation.Autowired;
  16. import org.springframework.util.StringUtils;
  17. import org.springframework.validation.BindingResult;
  18. import org.springframework.validation.ObjectError;
  19. import org.springframework.web.bind.annotation.*;
  20. import javax.servlet.http.HttpServletResponse;
  21. import javax.validation.Valid;
  22. import java.io.IOException;
  23. import java.time.LocalDateTime;
  24. /**
  25. * 反馈信息
  26. *
  27. * @author codingliang
  28. * @email codingliang@gmail.com
  29. * @date 2021-08-12 15:52:41
  30. */
  31. @RestController
  32. @RequestMapping("tuitionpayment/feedbackmsg")
  33. public class FeedbackMsgController {
  34. @Autowired
  35. private FeedbackMsgService feedbackMsgService;
  36. /**
  37. * 新增反馈信息
  38. *
  39. * @param cardNumber 当前登录者学号
  40. * @param feedbackMsgCreateTO 反馈信息to
  41. * @param result 数据校验异常绑定结果
  42. * @return
  43. */
  44. @PostMapping("/save")
  45. public CommonResult<String> save(@RequestHeader("card_number") String cardNumber,
  46. @Valid @RequestBody FeedbackMsgCreateTO feedbackMsgCreateTO,
  47. BindingResult result) {
  48. if (result.hasErrors()) {
  49. ObjectError error = result.getAllErrors().get(0);
  50. throw new RRException(BizCodeEnume.PARAMETER_ERROR, error.getDefaultMessage());
  51. }
  52. feedbackMsgCreateTO.setFeedbackNoticeType("1");
  53. feedbackMsgService.save(cardNumber, feedbackMsgCreateTO);
  54. return CommonResult.ok();
  55. }
  56. /**
  57. * 反馈列表【当前用户】
  58. *
  59. * @param cardNumber
  60. * @param pageParam
  61. * @return
  62. */
  63. @GetMapping("/listOfCurrentUser")
  64. public CommonResult<PageUtils<FeedbackMsgEntity>> listOfCurrentUser(@RequestHeader("card_number") String cardNumber,
  65. PageParam pageParam) {
  66. PageUtils page = feedbackMsgService.queryPage(cardNumber, pageParam);
  67. return CommonResult.ok().setResult(page);
  68. }
  69. /**
  70. * 反馈信息删除
  71. *
  72. * @param cardNumber 当前登录者学号
  73. * @param id 反馈信息id
  74. * @return
  75. */
  76. @DeleteMapping("/delete/{id}")
  77. public CommonResult<String> delete(@RequestHeader("card_number") String cardNumber,
  78. @PathVariable("id") Long id) {
  79. FeedbackMsgEntity entity = feedbackMsgService.getById(id);
  80. if (entity == null) {
  81. throw new RRException(BizCodeEnume.DATA_IS_NOT_EXIST, "反馈信息不存在");
  82. }
  83. if (!entity.getFeedbackPersonIdentify().equals(cardNumber)) {
  84. throw new RRException(BizCodeEnume.NO_PERMISSION);
  85. }
  86. feedbackMsgService.removeById(id);
  87. return CommonResult.ok();
  88. }
  89. /**
  90. * 反馈列表【管理员】
  91. * // * @param adminToken 管理员token
  92. *
  93. * @return
  94. * @apiNote 0.1.0新增keyword关键字查询
  95. * @since 0.0.1
  96. */
  97. // @AdminLoginCheck
  98. // @GetMapping("/list")
  99. // public CommonResult<PageUtils<FeedbackMsgEntity>> listOfAdmin(//@RequestHeader("admin_token") String adminToken,
  100. // String status,
  101. // String keyword,
  102. // PageParam pageParam){
  103. // PageUtils page = feedbackMsgService.queryPageByStatus(status, keyword, pageParam);
  104. //
  105. // return CommonResult.ok().setResult(page);
  106. // }
  107. // @AdminLoginCheck
  108. @PostMapping("/list")
  109. public CommonResult<PageUtils<FeedbackMsgEntity>> listOfAdmin( //@RequestHeader("admin_token") String adminToken,
  110. @RequestBody JSONObject jsonObject) {
  111. FeedbackMsgQueryVO feedbackMsgQueryVO = JSONObject.toJavaObject(jsonObject, FeedbackMsgQueryVO.class);
  112. PageUtils page = feedbackMsgService.queryPageVO(feedbackMsgQueryVO);
  113. return CommonResult.ok().setResult(page);
  114. }
  115. /**
  116. * 反馈详细信息
  117. *
  118. * @param adminToken 管理员token
  119. * @param id 反馈id
  120. * @return
  121. */
  122. @AdminLoginCheck
  123. @GetMapping("/info/{id}")
  124. public CommonResult<FeedbackMsgEntity> info(@RequestHeader("admin_token") String adminToken,
  125. @PathVariable("id") Long id) {
  126. FeedbackMsgEntity feedbackMsg = feedbackMsgService.getById(id);
  127. return CommonResult.ok().setResult(feedbackMsg);
  128. }
  129. /**
  130. * 反馈信息处理
  131. *
  132. * @param id 反馈id
  133. * @param content 反馈内容
  134. * @return
  135. * @apiNote 将反馈信息从未处理状态改变为已处理状态
  136. */
  137. @PutMapping("/info/{id}")
  138. public CommonResult<String> handleFeedbackMsg(@PathVariable("id") Long id,
  139. @RequestParam("content") String content) {
  140. FeedbackMsgEntity feedbackMsg = feedbackMsgService.getById(id);
  141. feedbackMsg.setStatu("2");
  142. feedbackMsg.setFeedbackDispose(content);
  143. feedbackMsg.setHandleTime(LocalDateTime.now());
  144. feedbackMsgService.updateById(feedbackMsg);
  145. return CommonResult.ok();
  146. }
  147. /**
  148. * 下载完成缴费的学生名单
  149. * <p>
  150. * // * @param adminToken 管理员token
  151. *
  152. * @param response
  153. * @apiNote 0.1.0新增按照支付方式下载字段
  154. */
  155. @RequestMapping("downloadResultMsg")
  156. public void downloadResultMsg(FeedbackMsgQueryVO feedbackMsgQueryVO,
  157. HttpServletResponse response) throws IOException {
  158. try {
  159. feedbackMsgService.downloadResultMsg(response, feedbackMsgQueryVO);
  160. } catch (Exception e) {
  161. e.printStackTrace();
  162. }
  163. }
  164. }