package com.yeshi.location.app.controller.client.api;
|
|
import com.yeshi.location.app.entity.feedback.Advice;
|
import com.yeshi.location.app.entity.feedback.PrivacyComplain;
|
import com.yeshi.location.app.service.inter.feedback.AdviceService;
|
import com.yeshi.location.app.service.inter.feedback.PrivacyComplainService;
|
import com.yeshi.location.app.vo.AcceptData;
|
import net.sf.json.JSONArray;
|
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.StringUtil;
|
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;
|
import java.io.PrintWriter;
|
import java.util.ArrayList;
|
import java.util.List;
|
|
/**
|
* @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("");
|
}
|
|
|
}
|