From 7e65ede92d1e6e31f36a66692ac3936c398be456 Mon Sep 17 00:00:00 2001 From: YunaiV Date: Fri, 27 Jan 2023 21:31:30 +0800 Subject: [PATCH] =?UTF-8?q?=E9=82=AE=E7=AE=B1=E6=A8=A1=E5=9D=97=EF=BC=9A?= =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=B3=A8=E9=87=8A=20+=20=E6=96=B9=E6=B3=95?= =?UTF-8?q?=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../module/system/api/mail/MailSendApi.java | 4 +-- .../system/api/mail/MailSendApiImpl.java | 4 +-- .../mail/MailAccountRefreshConsumer.java | 31 +++++++++++++++++++ .../mq/consumer/mail/MailSendConsumer.java | 8 ++++- .../mail/MailTemplateRefreshConsumer.java | 3 +- .../mail/MailAccountRefreshMessage.java | 4 ++- .../mail/MailTemplateRefreshMessage.java | 4 ++- .../system/mq/producer/mail/MailProducer.java | 2 +- 8 files changed, 51 insertions(+), 9 deletions(-) create mode 100644 yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/mq/consumer/mail/MailAccountRefreshConsumer.java diff --git a/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/mail/MailSendApi.java b/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/mail/MailSendApi.java index 3885259f2..542727795 100644 --- a/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/mail/MailSendApi.java +++ b/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/mail/MailSendApi.java @@ -19,7 +19,7 @@ public interface MailSendApi { * @param reqDTO 发送请求 * @return 发送日志编号 */ - Long sendSingleSmsToAdmin(@Valid MailSendSingleToUserReqDTO reqDTO); + Long sendSingleMailToAdmin(@Valid MailSendSingleToUserReqDTO reqDTO); /** * 发送单条邮箱给 Member 用户 @@ -29,6 +29,6 @@ public interface MailSendApi { * @param reqDTO 发送请求 * @return 发送日志编号 */ - Long sendSingleSmsToMember(@Valid MailSendSingleToUserReqDTO reqDTO); + Long sendSingleMailToMember(@Valid MailSendSingleToUserReqDTO reqDTO); } diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/api/mail/MailSendApiImpl.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/api/mail/MailSendApiImpl.java index 59648f5a5..72d03afbc 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/api/mail/MailSendApiImpl.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/api/mail/MailSendApiImpl.java @@ -20,13 +20,13 @@ public class MailSendApiImpl implements MailSendApi { private MailSendService mailSendService; @Override - public Long sendSingleSmsToAdmin(MailSendSingleToUserReqDTO reqDTO) { + public Long sendSingleMailToAdmin(MailSendSingleToUserReqDTO reqDTO) { return mailSendService.sendSingleMailToAdmin(reqDTO.getMail(), reqDTO.getUserId(), reqDTO.getTemplateCode(), reqDTO.getTemplateParams()); } @Override - public Long sendSingleSmsToMember(MailSendSingleToUserReqDTO reqDTO) { + public Long sendSingleMailToMember(MailSendSingleToUserReqDTO reqDTO) { return mailSendService.sendSingleMailToMember(reqDTO.getMail(), reqDTO.getUserId(), reqDTO.getTemplateCode(), reqDTO.getTemplateParams()); } diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/mq/consumer/mail/MailAccountRefreshConsumer.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/mq/consumer/mail/MailAccountRefreshConsumer.java new file mode 100644 index 000000000..69ddfce33 --- /dev/null +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/mq/consumer/mail/MailAccountRefreshConsumer.java @@ -0,0 +1,31 @@ +package cn.iocoder.yudao.module.system.mq.consumer.mail; + +import cn.iocoder.yudao.framework.mq.core.pubsub.AbstractChannelMessageListener; +import cn.iocoder.yudao.module.system.mq.message.mail.MailAccountRefreshMessage; +import cn.iocoder.yudao.module.system.mq.message.mail.MailTemplateRefreshMessage; +import cn.iocoder.yudao.module.system.service.mail.MailAccountService; +import cn.iocoder.yudao.module.system.service.mail.MailTemplateService; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + +import javax.annotation.Resource; + +/** + * 针对 {@link MailAccountRefreshMessage} 的消费者 + * + * @author wangjingyi + */ +@Component +@Slf4j +public class MailAccountRefreshConsumer extends AbstractChannelMessageListener { + + @Resource + private MailAccountService mailAccountService; + + @Override + public void onMessage(MailAccountRefreshMessage message) { + log.info("[onMessage][收到 Mail Account 刷新信息]"); + mailAccountService.initLocalCache(); + } + +} diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/mq/consumer/mail/MailSendConsumer.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/mq/consumer/mail/MailSendConsumer.java index 978ea5997..3cff145b8 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/mq/consumer/mail/MailSendConsumer.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/mq/consumer/mail/MailSendConsumer.java @@ -2,19 +2,25 @@ package cn.iocoder.yudao.module.system.mq.consumer.mail; import cn.iocoder.yudao.framework.mq.core.stream.AbstractStreamMessageListener; import cn.iocoder.yudao.module.system.mq.message.mail.MailSendMessage; +import cn.iocoder.yudao.module.system.mq.message.sms.SmsSendMessage; import cn.iocoder.yudao.module.system.service.mail.MailSendService; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Component; import javax.annotation.Resource; - +/** + * 针对 {@link MailSendMessage} 的消费者 + * + * @author 芋道源码 + */ @Component @Slf4j public class MailSendConsumer extends AbstractStreamMessageListener { @Resource private MailSendService mailSendService; + @Override public void onMessage(MailSendMessage message) { log.info("[onMessage][消息内容({})]", message); diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/mq/consumer/mail/MailTemplateRefreshConsumer.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/mq/consumer/mail/MailTemplateRefreshConsumer.java index 199b147c8..35da1edec 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/mq/consumer/mail/MailTemplateRefreshConsumer.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/mq/consumer/mail/MailTemplateRefreshConsumer.java @@ -22,7 +22,8 @@ public class MailTemplateRefreshConsumer extends AbstractChannelMessageListener< @Override public void onMessage(MailTemplateRefreshMessage message) { - log.info("[onMessage][收到 MailTemplate 刷新信息]"); + log.info("[onMessage][收到 Mail Template 刷新信息]"); mailTemplateService.initLocalCache(); } + } diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/mq/message/mail/MailAccountRefreshMessage.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/mq/message/mail/MailAccountRefreshMessage.java index d5eafb04d..d6e9d08a9 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/mq/message/mail/MailAccountRefreshMessage.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/mq/message/mail/MailAccountRefreshMessage.java @@ -5,15 +5,17 @@ import lombok.Data; import lombok.EqualsAndHashCode; /** - * 邮箱账号的数据刷新 Message + * 邮箱账号的数据刷新 Message * * @author wangjingyi */ @Data @EqualsAndHashCode(callSuper = true) public class MailAccountRefreshMessage extends AbstractChannelMessage { + @Override public String getChannel() { return "system.mail-account.refresh"; } + } diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/mq/message/mail/MailTemplateRefreshMessage.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/mq/message/mail/MailTemplateRefreshMessage.java index 476411ca1..f6ff0925a 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/mq/message/mail/MailTemplateRefreshMessage.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/mq/message/mail/MailTemplateRefreshMessage.java @@ -5,15 +5,17 @@ import lombok.Data; import lombok.EqualsAndHashCode; /** - * 邮箱模板的数据刷新 Message + * 邮箱模板的数据刷新 Message * * @author wangjingyi */ @Data @EqualsAndHashCode(callSuper = true) public class MailTemplateRefreshMessage extends AbstractChannelMessage { + @Override public String getChannel() { return "system.mail-template.refresh"; } + } diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/mq/producer/mail/MailProducer.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/mq/producer/mail/MailProducer.java index 19de302fd..afa958cd7 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/mq/producer/mail/MailProducer.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/mq/producer/mail/MailProducer.java @@ -31,7 +31,7 @@ public class MailProducer { } /** - * 发送 {@link MailTemplateRefreshMessage} 消息 + * 发送 {@link MailAccountRefreshMessage} 消息 */ public void sendMailAccountRefreshMessage() { MailAccountRefreshMessage message = new MailAccountRefreshMessage();