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); }