refactor: 发送邮件代码重构

This commit is contained in:
Captain.B 2020-09-25 10:23:08 +08:00
parent b5ea0a3d50
commit c4f1e23291
1 changed files with 13 additions and 14 deletions

View File

@ -118,6 +118,19 @@ public class MailService {
}
}
public void sendCommentNotice(List<String> userIds, SaveCommentRequest request, TestCaseWithBLOBs testCaseWithBLOBs) {
Map<String, String> context = new HashMap<>();
context.put("maintainer", testCaseWithBLOBs.getMaintainer());
context.put("testCaseName", testCaseWithBLOBs.getName());
context.put("description", request.getDescription());
try {
String commentTemplate = IOUtils.toString(this.getClass().getResource("/mail/comment.html"), StandardCharsets.UTF_8);
sendHtml(userIds, context, commentTemplate);
} catch (Exception e) {
LogUtil.error(e);
}
}
public void sendReviewerNotice(List<String> userIds, SaveTestCaseReviewRequest reviewRequest) {
Map<String, String> context = getReviewContext(reviewRequest);
@ -150,20 +163,6 @@ public class MailService {
javaMailSender.send(mimeMessage);
}
public void sendCommentNotice(List<String> userIds, SaveCommentRequest request, TestCaseWithBLOBs testCaseWithBLOBs) {
Map<String, String> context = new HashMap<>();
context.put("maintainer", testCaseWithBLOBs.getMaintainer());
context.put("testCaseName", testCaseWithBLOBs.getName());
context.put("description", request.getDescription());
try {
String commentTemplate = IOUtils.toString(this.getClass().getResource("/mail/comment.html"), StandardCharsets.UTF_8);
sendHtml(userIds, context, commentTemplate);
} catch (Exception e) {
LogUtil.error(e);
}
}
private Map<String, String> getReviewContext(SaveTestCaseReviewRequest reviewRequest) {
Long startTime = reviewRequest.getCreateTime();
Long endTime = reviewRequest.getEndTime();