| | |
| | | } |
| | | |
| | | /** |
| | | * 根据任务ID和用户ID查询发送记录 |
| | | */ |
| | | @Override |
| | | public NotifySendLog selectNotifySendLog(Long taskId, Long userId, String notifyType, String channel) { |
| | | return notifySendLogMapper.selectNotifySendLog(taskId, userId, notifyType, channel); |
| | | } |
| | | |
| | | /** |
| | | * 检查是否已发送过通知(防重检查) |
| | | * |
| | | * @param taskId 任务ID |
| | |
| | | } |
| | | |
| | | /** |
| | | * 更新发送状态为成功 |
| | | * 更新发送状态为成功(向后兼容) |
| | | * |
| | | * @param id 记录ID |
| | | * @param result 发送结果信息 |
| | | */ |
| | | @Override |
| | | public void markSendSuccess(Long id, String result) { |
| | | markSendSuccess(id, result, null); |
| | | } |
| | | |
| | | /** |
| | | * 更新发送状态为成功 |
| | | * |
| | | * @param id 记录ID |
| | | * @param result 发送结果信息 |
| | | * @param content 发送内容 |
| | | */ |
| | | @Override |
| | | public void markSendSuccess(Long id, String result, String content) { |
| | | if (id == null) { |
| | | return; |
| | | } |
| | | try { |
| | | notifySendLogMapper.updateSendStatus(id, NotifySendLog.SEND_STATUS_SUCCESS, result); |
| | | notifySendLogMapper.updateSendStatus(id, NotifySendLog.SEND_STATUS_SUCCESS, result, content); |
| | | log.debug("更新通知发送状态为成功,id={}", id); |
| | | } catch (Exception e) { |
| | | log.error("更新通知发送状态失败,id={}", id, e); |
| | |
| | | } |
| | | |
| | | /** |
| | | * 更新发送状态为失败 |
| | | * 更新发送状态为失败(向后兼容) |
| | | * |
| | | * @param id 记录ID |
| | | * @param errorMsg 错误信息 |
| | | */ |
| | | @Override |
| | | public void markSendFailed(Long id, String errorMsg) { |
| | | markSendFailed(id, errorMsg, null); |
| | | } |
| | | |
| | | /** |
| | | * 更新发送状态为失败 |
| | | * |
| | | * @param id 记录ID |
| | | * @param errorMsg 错误信息 |
| | | * @param content 发送内容 |
| | | */ |
| | | @Override |
| | | public void markSendFailed(Long id, String errorMsg, String content) { |
| | | if (id == null) { |
| | | return; |
| | | } |
| | |
| | | if (errorMsg != null && errorMsg.length() > 500) { |
| | | errorMsg = errorMsg.substring(0, 500); |
| | | } |
| | | notifySendLogMapper.updateSendStatus(id, NotifySendLog.SEND_STATUS_FAILED, errorMsg); |
| | | notifySendLogMapper.updateSendStatus(id, NotifySendLog.SEND_STATUS_FAILED, errorMsg, content); |
| | | log.debug("更新通知发送状态为失败,id={}, error={}", id, errorMsg); |
| | | } catch (Exception e) { |
| | | log.error("更新通知发送状态失败,id={}", id, e); |
| | |
| | | * @param maxRetryCount 最大重试次数 |
| | | * @return 失败记录列表 |
| | | */ |
| | | @Override |
| | | |
| | | public List<NotifySendLog> selectFailedNotifySendLogs(Integer maxRetryCount) { |
| | | return notifySendLogMapper.selectFailedNotifySendLogs(maxRetryCount); |
| | | } |