|
|
@ -4,6 +4,8 @@ import java.nio.charset.Charset;
|
|
|
|
import java.util.HashMap;
|
|
|
|
import java.util.HashMap;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.Map;
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.http.HttpEntity;
|
|
|
|
import org.springframework.http.HttpEntity;
|
|
|
|
import org.springframework.http.HttpHeaders;
|
|
|
|
import org.springframework.http.HttpHeaders;
|
|
|
@ -15,22 +17,32 @@ import org.springframework.stereotype.Service;
|
|
|
|
import org.springframework.web.client.RestTemplate;
|
|
|
|
import org.springframework.web.client.RestTemplate;
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
import com.luoo.user.dao.FeedbackDao;
|
|
|
|
import com.luoo.user.dao.FeedbackDao;
|
|
|
|
|
|
|
|
import com.luoo.user.dto.FeedbackImage;
|
|
|
|
import com.luoo.user.pojo.Feedback;
|
|
|
|
import com.luoo.user.pojo.Feedback;
|
|
|
|
import com.luoo.user.util.EmojiConverterUtil;
|
|
|
|
import com.luoo.user.util.EmojiConverterUtil;
|
|
|
|
|
|
|
|
|
|
|
|
import constants.Constants;
|
|
|
|
import constants.Constants;
|
|
|
|
|
|
|
|
import lombok.SneakyThrows;
|
|
|
|
|
|
|
|
import util.IdWorker;
|
|
|
|
|
|
|
|
import util.StringTools;
|
|
|
|
|
|
|
|
|
|
|
|
@Service
|
|
|
|
@Service
|
|
|
|
public class FeedbackService {
|
|
|
|
public class FeedbackService {
|
|
|
|
private static final String[] EMPTY_IMAGE_ARRAY = new String[] {};
|
|
|
|
private static final String[] EMPTY_IMAGE_ARRAY = new String[] {};
|
|
|
|
private static final String FEI_SHU_URL = "https://open.feishu.cn/open-apis/bot/v2/hook/84316603-355a-4dea-bb86-65f4b8919431";
|
|
|
|
private static final String FEI_SHU_URL = "https://open.feishu.cn/open-apis/bot/v2/hook/84316603-355a-4dea-bb86-65f4b8919431";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
|
|
private S3Service s3Service;
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
|
|
private IdWorker idWorker;
|
|
|
|
@Autowired
|
|
|
|
@Autowired
|
|
|
|
private FeedbackDao feedbackDao;
|
|
|
|
private FeedbackDao feedbackDao;
|
|
|
|
@Autowired
|
|
|
|
@Autowired
|
|
|
|
private RestTemplate restTemplate;
|
|
|
|
private RestTemplate restTemplate;
|
|
|
|
|
|
|
|
|
|
|
|
@Async
|
|
|
|
@Async
|
|
|
|
public void send(Feedback feedback) {
|
|
|
|
public void send(Feedback feedback,List<FeedbackImage> files) {
|
|
|
|
|
|
|
|
feedback.setImages(uploadImages(feedback, files));
|
|
|
|
feedbackDao.save(feedback);
|
|
|
|
feedbackDao.save(feedback);
|
|
|
|
seedToFeishu(feedback);
|
|
|
|
seedToFeishu(feedback);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -64,4 +76,20 @@ public class FeedbackService {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
restTemplate.postForEntity(FEI_SHU_URL, requestEntity, Map.class);
|
|
|
|
restTemplate.postForEntity(FEI_SHU_URL, requestEntity, Map.class);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private String uploadImages(Feedback feedback, List<FeedbackImage> files) {
|
|
|
|
|
|
|
|
if (null == files || files.isEmpty()) {
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return files.parallelStream().map(f -> uploadImages(feedback, f)).collect(Collectors.joining(","));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@SneakyThrows
|
|
|
|
|
|
|
|
private String uploadImages(Feedback feedback, FeedbackImage file) {
|
|
|
|
|
|
|
|
String imageName = feedback.getUserId() + "_" + feedback.getFeedbackId() + "_" + idWorker.nextId()
|
|
|
|
|
|
|
|
+ StringTools.getFileSuffix(file.getOriginalFilename());
|
|
|
|
|
|
|
|
String filePath = Constants.USER_FEEDBACK_IMAGE_DIRECTORY + imageName;
|
|
|
|
|
|
|
|
s3Service.upload("indie", filePath, file);
|
|
|
|
|
|
|
|
return imageName;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|