From 935b2cdb5a2a4749d550b63f1e43fc4a2b8824d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=87=E4=BD=B3?= Date: Fri, 17 Sep 2021 13:35:28 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E5=AE=8C=E5=96=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../executor/service/email/EmailService.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/executor/src/main/java/cn/org/gitlink/notification/executor/service/email/EmailService.java b/executor/src/main/java/cn/org/gitlink/notification/executor/service/email/EmailService.java index d976f97..9f06fe4 100644 --- a/executor/src/main/java/cn/org/gitlink/notification/executor/service/email/EmailService.java +++ b/executor/src/main/java/cn/org/gitlink/notification/executor/service/email/EmailService.java @@ -24,10 +24,16 @@ public class EmailService { private Logger logger = LogManager.getLogger(EmailService.class); + //邮件任务处理状态 private static final Integer EMAIL_JOB_NOT_DISPATCHED = -1; //处理成功 private static final Integer EMAIL_JOB_DISPATCHED_SUCCESS = 1; //处理成功 private static final Integer EMAIL_JOB_DISPATCHED_FAIL = 2; //处理失败 + //邮件发送记录状态 + private static final Integer EMAIL_UNSENT_RECORD = -1; //处理成功 + private static final Integer EMAIL_SENT_SUCCESS = 1; //处理成功 + private static final Integer EMAIL_SENT_FAIL = 2; //处理失败 + @Autowired private EmailJobsService emailJobsService; @@ -85,7 +91,7 @@ public class EmailService { //获取待发送列表 List emailSendRecordList = new ArrayList<>(); try { - emailSendRecordList = emailSendRecordsService.getRecordsByStatus(platform, -1, sentNumber); + emailSendRecordList = emailSendRecordsService.getRecordsByStatus(platform, EMAIL_UNSENT_RECORD, sentNumber); } catch (Exception e) { logger.error("获取未发送邮件列表失败:\n" + e); } @@ -98,7 +104,7 @@ public class EmailService { emailUtils.sendMail(unSentEmailSendRecord.getSubject(), unSentEmailSendRecord.getEmail(), unSentEmailSendRecord.getContent()); flag = true; unSentEmailSendRecord.setSentAt(new Date()); - unSentEmailSendRecord.setStatus(flag ? 1 : 2); + unSentEmailSendRecord.setStatus(flag ? EMAIL_SENT_SUCCESS : EMAIL_SENT_FAIL); } catch (MessagingException e) { logger.error("发送邮件失败,email: " + unSentEmailSendRecord.getEmail() + "\n" + e); }