Merge pull request '时区配置' (#100) from wanjia9506/gitlink-notification-system:dev_gitlink_model into master
This commit is contained in:
commit
728efe9a57
|
|
@ -21,10 +21,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;
|
||||
|
||||
|
|
@ -35,7 +41,8 @@ public class EmailService {
|
|||
private EmailUtils emailUtils;
|
||||
|
||||
/**
|
||||
* 处理邮件发送任务,根据emails添加到邮件发送记录表中。
|
||||
* 处理邮件发送任务,根据emails添加到邮件发送记录表中
|
||||
*
|
||||
* @param platform 平台编码
|
||||
* @param dispatchNumber 待处理发送任务列表数量
|
||||
* @return: void
|
||||
|
|
@ -71,6 +78,7 @@ public class EmailService {
|
|||
|
||||
/**
|
||||
* 发送邮件
|
||||
*
|
||||
* @param platform 平台编码
|
||||
* @param sentNumber 一次发送数量
|
||||
* @return: void
|
||||
|
|
@ -82,7 +90,7 @@ public class EmailService {
|
|||
//获取待发送列表
|
||||
List<EmailSendRecord> 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);
|
||||
}
|
||||
|
|
@ -95,7 +103,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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,4 +46,12 @@ spring:
|
|||
url: jdbc:mysql://mysql:3306/gitlink_notification?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&serverTimezone=GMT%2B8&allowMultiQueries=true&useSSL=false
|
||||
username: gitlink
|
||||
password: giTlinK0^827
|
||||
|
||||
jackson:
|
||||
date-format: yyyy-MM-dd HH:mm:ss
|
||||
time-zone: GMT+8
|
||||
serialization:
|
||||
indent_output: true
|
||||
fail_on_empty_beans: false
|
||||
|
||||
white-list: '*'
|
||||
|
|
@ -126,8 +126,6 @@
|
|||
limit #{size}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
|
||||
<update id="updateEmailSendRecordsBatch" parameterType="list">
|
||||
update ${platform}_email_send_records
|
||||
<trim prefix="set" suffixOverrides=",">
|
||||
|
|
|
|||
|
|
@ -30,4 +30,11 @@ spring:
|
|||
username: gitlink
|
||||
password: giTlinK0^827
|
||||
|
||||
jackson:
|
||||
date-format: yyyy-MM-dd HH:mm:ss
|
||||
time-zone: GMT+8
|
||||
serialization:
|
||||
indent_output: true
|
||||
fail_on_empty_beans: false
|
||||
|
||||
white-list: '*'
|
||||
|
|
@ -47,7 +47,7 @@ public class EmailJobsController {
|
|||
@ApiOperation("发送邮件任务")
|
||||
@RequestMapping(path = "/{platform}", method = RequestMethod.POST)
|
||||
@ResponseBody
|
||||
public ResponseData sendNotification(@ApiParam(value = "平台编码", required = true)
|
||||
public ResponseData sendEmail(@ApiParam(value = "平台编码", required = true)
|
||||
@PathVariable(name = "platform") String platform,
|
||||
|
||||
@Validated @RequestBody NewEmailJobParamsVo newEmailJobParamsVo,
|
||||
|
|
|
|||
|
|
@ -32,4 +32,12 @@ spring:
|
|||
url: jdbc:mysql://mysql:3306/gitlink_notification?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&serverTimezone=GMT%2B8&allowMultiQueries=true&useSSL=false
|
||||
username: gitlink
|
||||
password: giTlinK0^827
|
||||
|
||||
jackson:
|
||||
date-format: yyyy-MM-dd HH:mm:ss
|
||||
time-zone: GMT+8
|
||||
serialization:
|
||||
indent_output: true
|
||||
fail_on_empty_beans: false
|
||||
|
||||
white-list: '*'
|
||||
Loading…
Reference in New Issue