puzhibing
2022-08-22 1421f8e9c308c4741cb396309035009393b5b036
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
package com.stylefeng.guns.modular.system.service.impl;
 
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.stylefeng.guns.core.util.ToolUtil;
import com.stylefeng.guns.modular.system.dao.FeedbackMapper;
import com.stylefeng.guns.modular.system.dao.SensitiveWordsMapper;
import com.stylefeng.guns.modular.system.model.Feedback;
import com.stylefeng.guns.modular.system.model.SensitiveWords;
import com.stylefeng.guns.modular.system.service.IFeedbackService;
import com.stylefeng.guns.modular.system.service.ISystemNoticeService;
import com.stylefeng.guns.modular.system.util.ResultUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
 
import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
 
 
@Service
public class FeedbackServiceImpl extends ServiceImpl<FeedbackMapper, Feedback> implements IFeedbackService {
 
    @Resource
    private SensitiveWordsMapper sensitiveWordsMapper;
 
    @Autowired
    private ISystemNoticeService systemNoticeService;
 
 
 
 
    /**
     * 反馈操作
     * @param content
     * @param uid
     * @throws Exception
     */
    @Override
    public ResultUtil feedback(String content, Integer uid) throws Exception {
        if(ToolUtil.isNotEmpty(content)){
            if(content.length() > 200){
                return ResultUtil.error("反馈内容过长");
            }
            List<SensitiveWords> sensitiveWords = sensitiveWordsMapper.selectList(null);
            for(SensitiveWords s : sensitiveWords){
                content = content.replaceAll(s.getContent(), "***");
            }
        }
 
        Feedback feedback = new Feedback();
        feedback.setContent(content);
        feedback.setFlag(1);
        feedback.setInsertTime(new Date());
        feedback.setState(1);
        feedback.setType(1);
        feedback.setUserId(uid);
        this.insert(feedback);
 
        systemNoticeService.addSystemNotice(1, "您的反馈已提交成功,我们会尽快处理!", uid, 1);
        return ResultUtil.success();
    }
}