无关风月
2024-07-10 6b96492c540e24cc29d55573c5816df808279825
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
package com.ruoyi.management.controller;
 
 
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.web.page.PageInfo;
import com.ruoyi.common.security.service.TokenService;
import com.ruoyi.management.domain.TFeedback;
import com.ruoyi.management.domain.TUseGuide;
import com.ruoyi.management.dto.FeedbackQuery;
import com.ruoyi.management.query.UseGuideQuery;
import com.ruoyi.management.service.ITFeedbackService;
import com.ruoyi.management.vo.FeedbackVO;
import com.ruoyi.study.api.domain.TUser;
import com.ruoyi.study.api.feignClient.StudyClient;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;
 
import java.util.ArrayList;
import java.util.List;
 
/**
 * <p>
 * 用户反馈 前端控制器
 * </p>
 *
 * @author 无关风月
 * @since 2024-04-26
 */
@Controller
@RequestMapping("/tFeedback")
public class TFeedbackController {
    @Autowired
    private ITFeedbackService feedbackService;
 
    @PostMapping("/addFeedBack")
    @ApiOperation(value = "反馈", tags = {"家长端-意见反馈"})
    public R addFeedBack(@RequestBody TFeedback dto) {
        feedbackService.save(dto);
        return R.ok();
    }
 
    @Autowired
    private StudyClient studyClient;
    @ResponseBody
    @PostMapping("/listAll")
    @ApiOperation(value = "列表查询", tags = {"反馈管理"})
    public AjaxResult<PageInfo<FeedbackVO>> listAll(FeedbackQuery query){
//        if (query.getEndTime()!=null){
//            query.getEndTime().setHours(23);
//            query.getEndTime().setMinutes(59);
//            query.getEndTime().setSeconds(59);
//        }
        List<FeedbackVO> list = feedbackService.listAll(query);
        List<FeedbackVO> result = new ArrayList<>();
        for (FeedbackVO feedbackVO : list) {
            TUser data = studyClient.getUserById(feedbackVO.getUserId()).getData();
            if (data == null )continue;
 
            feedbackVO.setName(data.getName());
            feedbackVO.setPhone(data.getPhone());
            if (!StringUtils.hasLength(query.getPhone()) && !StringUtils.hasLength(query.getUserName())) {
                result.add(feedbackVO);
                continue;
            }
            // 如果筛选条件输入了电话或者姓名那么需要过滤掉不符合条件的数据
            if (StringUtils.hasLength(query.getPhone()) && StringUtils.hasLength(query.getUserName())) {
                if (feedbackVO.getPhone().contains(query.getPhone()) && feedbackVO.getName().contains(query.getUserName())) {
                    result.add(feedbackVO);
                }
            } else if (StringUtils.hasLength(query.getPhone())) {
                if (feedbackVO.getPhone().contains(query.getPhone())) {
                    result.add(feedbackVO);
                }
            } else if (StringUtils.hasLength(query.getUserName())) {
                if (feedbackVO.getName().contains(query.getUserName())) {
                    result.add(feedbackVO);
                }
            }
        }
        PageInfo<FeedbackVO> res = new PageInfo<>(query.getPageNumber(), query.getPageSize());
        res.setTotal(result.size());
        res.setRecords(result);
        return AjaxResult.success(res);
    }
 
    @ResponseBody
    @GetMapping("/detail")
    @ApiOperation(value = "查看详情", tags = {"反馈管理"})
    public AjaxResult<TFeedback> detail(Integer id){
        TFeedback feedback = feedbackService.getById(id);
        return AjaxResult.success(feedback);
    }
 
    @ResponseBody
    @GetMapping("/handle")
    @ApiOperation(value = "处理", tags = {"反馈管理"})
    public AjaxResult handle(Integer id){
        TFeedback feedback = feedbackService.getById(id);
        feedback.setState(2);
        feedbackService.updateById(feedback);
        return AjaxResult.success();
    }
}