admin
2021-12-09 f609ca35ee2946acd0ff04b7ac1aa61f75a2e4a1
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
109
110
111
112
113
114
115
package com.ks.app.controller.client.api;
 
import com.ks.app.entity.feedback.Advice;
import com.ks.app.service.inter.feedback.AdviceService;
import com.ks.app.service.inter.feedback.PrivacyComplainService;
import com.ks.app.vo.AcceptData;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import org.yeshi.utils.JsonUtil;
import org.yeshi.utils.TimeUtil;
import org.yeshi.utils.annotation.RequestSerializableByKey;
import org.yeshi.utils.entity.FileUploadResult;
import org.yeshi.utils.tencentcloud.COSManager;
 
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
 
/**
 * @author hxh
 * @title: UserController
 * @description: 用户反馈接口
 * @date 2021/11/16 17:37
 */
@Controller
@RequestMapping("api/v1/feedback")
public class FeedBackController {
 
    Logger logger = LoggerFactory.getLogger(FeedBackController.class);
 
    @Resource
    private AdviceService adviceService;
 
    @Resource
    private PrivacyComplainService privacyComplainService;
 
 
    /**
     * @return java.lang.String
     * @author hxh
     * @description 建议
     * @date 13:15 2021/12/2
     * @param: acceptData
     * @param: uid
     * @param: type
     * @param: content
     **/
    @RequestMapping("advice")
    @ResponseBody
    public String advice(AcceptData acceptData, Long uid, String type, String content) {
        Advice advice = new Advice();
        advice.setContent(content);
        advice.setType(type);
        advice.setDevice(acceptData.getUtdId());
        advice.setUid(uid);
 
        try {
            adviceService.add(advice);
            return JsonUtil.loadTrueResult("");
        } catch (Exception e) {
            return JsonUtil.loadFalseResult(e.getMessage());
        }
    }
 
 
    /**
     * @return java.lang.String
     * @author hxh
     * @description 隐私投诉
     * @date 19:14 2021/10/15
     * @param: acceptData
     * @param: loginUid
     **/
    @RequestSerializableByKey(key = "#acceptData.utdId")
    @RequestMapping("privacyComplain")
    @ResponseBody
    public String privacyComplain(AcceptData acceptData, HttpServletRequest request, MultipartFile[] images) {
 
        String content = request.getParameter("content");
 
        String urlList = "";
        if (images != null && images.length > 0) {
            for (MultipartFile f : images) {
                try {
                    String name = TimeUtil.getGernalTime(System.currentTimeMillis(), "yyyyMMddHHmmssSSS") + "_" + ((int) (Math.random() * 100000)) + ".jpg";
                    FileUploadResult result = COSManager.getInstance().uploadFile(f.getInputStream(), "privacy/report/" + name);
                    if (result != null) {
                        urlList += result.getUrl() + " , ";
                    }
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
//        String title = "隐私投诉:" + content;
        StringBuffer buffer = new StringBuffer();
        buffer.append("包名:" + acceptData.getPackages());
        buffer.append("\n\r");
        buffer.append("UTDID:" + acceptData.getUtdId());
        buffer.append("\n\r");
        buffer.append("投诉内容:");
        buffer.append(content);
        buffer.append("\n\r");
        buffer.append("提供的截图为:" + urlList);
        logger.info("隐私投诉:" + buffer.toString());
//        MailSenderUtil.sendEmail("yesbd@qq.com", "buwanysdq@163.com", "weikou2014", title, buffer.toString());
        return JsonUtil.loadTrueResult("");
    }
 
 
}