| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184 |
- package com.chuanghai.smartschool.tuitionpayment.controller;
- import com.alibaba.fastjson.JSONObject;
- import com.chuanghai.smartschool.tuitionpayment.anno.AdminLoginCheck;
- import com.chuanghai.smartschool.tuitionpayment.common.exception.BizCodeEnume;
- import com.chuanghai.smartschool.tuitionpayment.common.exception.RRException;
- import com.chuanghai.smartschool.tuitionpayment.common.utils.CommonResult;
- import com.chuanghai.smartschool.tuitionpayment.common.utils.PageParam;
- import com.chuanghai.smartschool.tuitionpayment.common.utils.PageUtils;
- import com.chuanghai.smartschool.tuitionpayment.entity.FeedbackMsgEntity;
- import com.chuanghai.smartschool.tuitionpayment.service.FeedbackMsgService;
- import com.chuanghai.smartschool.tuitionpayment.to.FeedbackMsgCreateTO;
- import com.chuanghai.smartschool.tuitionpayment.to.PayOrderQueryTO;
- import com.chuanghai.smartschool.tuitionpayment.vo.FeedbackMsgQueryVO;
- import org.apache.poi.ss.formula.functions.T;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.util.StringUtils;
- import org.springframework.validation.BindingResult;
- import org.springframework.validation.ObjectError;
- import org.springframework.web.bind.annotation.*;
- import javax.servlet.http.HttpServletResponse;
- import javax.validation.Valid;
- import java.io.IOException;
- import java.time.LocalDateTime;
- /**
- * 反馈信息
- *
- * @author codingliang
- * @email codingliang@gmail.com
- * @date 2021-08-12 15:52:41
- */
- @RestController
- @RequestMapping("tuitionpayment/feedbackmsg")
- public class FeedbackMsgController {
- @Autowired
- private FeedbackMsgService feedbackMsgService;
- /**
- * 新增反馈信息
- *
- * @param cardNumber 当前登录者学号
- * @param feedbackMsgCreateTO 反馈信息to
- * @param result 数据校验异常绑定结果
- * @return
- */
- @PostMapping("/save")
- public CommonResult<String> save(@RequestHeader("card_number") String cardNumber,
- @Valid @RequestBody FeedbackMsgCreateTO feedbackMsgCreateTO,
- BindingResult result) {
- if (result.hasErrors()) {
- ObjectError error = result.getAllErrors().get(0);
- throw new RRException(BizCodeEnume.PARAMETER_ERROR, error.getDefaultMessage());
- }
- feedbackMsgCreateTO.setFeedbackNoticeType("1");
- feedbackMsgService.save(cardNumber, feedbackMsgCreateTO);
- return CommonResult.ok();
- }
- /**
- * 反馈列表【当前用户】
- *
- * @param cardNumber
- * @param pageParam
- * @return
- */
- @GetMapping("/listOfCurrentUser")
- public CommonResult<PageUtils<FeedbackMsgEntity>> listOfCurrentUser(@RequestHeader("card_number") String cardNumber,
- PageParam pageParam) {
- PageUtils page = feedbackMsgService.queryPage(cardNumber, pageParam);
- return CommonResult.ok().setResult(page);
- }
- /**
- * 反馈信息删除
- *
- * @param cardNumber 当前登录者学号
- * @param id 反馈信息id
- * @return
- */
- @DeleteMapping("/delete/{id}")
- public CommonResult<String> delete(@RequestHeader("card_number") String cardNumber,
- @PathVariable("id") Long id) {
- FeedbackMsgEntity entity = feedbackMsgService.getById(id);
- if (entity == null) {
- throw new RRException(BizCodeEnume.DATA_IS_NOT_EXIST, "反馈信息不存在");
- }
- if (!entity.getFeedbackPersonIdentify().equals(cardNumber)) {
- throw new RRException(BizCodeEnume.NO_PERMISSION);
- }
- feedbackMsgService.removeById(id);
- return CommonResult.ok();
- }
- /**
- * 反馈列表【管理员】
- * // * @param adminToken 管理员token
- *
- * @return
- * @apiNote 0.1.0新增keyword关键字查询
- * @since 0.0.1
- */
- // @AdminLoginCheck
- // @GetMapping("/list")
- // public CommonResult<PageUtils<FeedbackMsgEntity>> listOfAdmin(//@RequestHeader("admin_token") String adminToken,
- // String status,
- // String keyword,
- // PageParam pageParam){
- // PageUtils page = feedbackMsgService.queryPageByStatus(status, keyword, pageParam);
- //
- // return CommonResult.ok().setResult(page);
- // }
- // @AdminLoginCheck
- @PostMapping("/list")
- public CommonResult<PageUtils<FeedbackMsgEntity>> listOfAdmin( //@RequestHeader("admin_token") String adminToken,
- @RequestBody JSONObject jsonObject) {
- FeedbackMsgQueryVO feedbackMsgQueryVO = JSONObject.toJavaObject(jsonObject, FeedbackMsgQueryVO.class);
- PageUtils page = feedbackMsgService.queryPageVO(feedbackMsgQueryVO);
- return CommonResult.ok().setResult(page);
- }
- /**
- * 反馈详细信息
- *
- * @param adminToken 管理员token
- * @param id 反馈id
- * @return
- */
- @AdminLoginCheck
- @GetMapping("/info/{id}")
- public CommonResult<FeedbackMsgEntity> info(@RequestHeader("admin_token") String adminToken,
- @PathVariable("id") Long id) {
- FeedbackMsgEntity feedbackMsg = feedbackMsgService.getById(id);
- return CommonResult.ok().setResult(feedbackMsg);
- }
- /**
- * 反馈信息处理
- *
- * @param id 反馈id
- * @param content 反馈内容
- * @return
- * @apiNote 将反馈信息从未处理状态改变为已处理状态
- */
- @PutMapping("/info/{id}")
- public CommonResult<String> handleFeedbackMsg(@PathVariable("id") Long id,
- @RequestParam("content") String content) {
- FeedbackMsgEntity feedbackMsg = feedbackMsgService.getById(id);
- feedbackMsg.setStatu("2");
- feedbackMsg.setFeedbackDispose(content);
- feedbackMsg.setHandleTime(LocalDateTime.now());
- feedbackMsgService.updateById(feedbackMsg);
- return CommonResult.ok();
- }
- /**
- * 下载完成缴费的学生名单
- * <p>
- * // * @param adminToken 管理员token
- *
- * @param response
- * @apiNote 0.1.0新增按照支付方式下载字段
- */
- @RequestMapping("downloadResultMsg")
- public void downloadResultMsg(FeedbackMsgQueryVO feedbackMsgQueryVO,
- HttpServletResponse response) throws IOException {
- try {
- feedbackMsgService.downloadResultMsg(response, feedbackMsgQueryVO);
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- }
|