From 4c0f5eb8aa744649102aa30b32db4d275de9d214 Mon Sep 17 00:00:00 2001
From: smallbun <2689170096@qq.com>
Date: Sat, 26 Aug 2023 18:12:05 +0800
Subject: [PATCH] =?UTF-8?q?:zap:=20=E4=BC=98=E5=8C=96=E7=9F=AD=E4=BF=A1/?=
=?UTF-8?q?=E9=82=AE=E4=BB=B6=E5=8F=91=E9=80=81=E6=9C=AA=E9=85=8D=E7=BD=AE?=
=?UTF-8?q?=E6=8F=90=E7=A4=BA?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../exception/MailProviderException.java | 2 +-
.../exception/SmsMessageSendException.java | 58 ++++++++++
.../SmsProviderException.java | 5 +-
.../common/message/SendMessageException.java | 105 ------------------
.../mail/DefaultMailProviderSendImpl.java | 5 +-
.../core/mq/AbstractMessageListener.java | 3 +-
.../core/mq/NoticeMessageListener.java | 15 ++-
.../employee/core/mq/UserMessageListener.java | 2 +-
8 files changed, 79 insertions(+), 116 deletions(-)
create mode 100644 eiam-common/src/main/java/cn/topiam/employee/common/exception/SmsMessageSendException.java
rename eiam-common/src/main/java/cn/topiam/employee/common/{message => exception}/SmsProviderException.java (97%)
delete mode 100644 eiam-common/src/main/java/cn/topiam/employee/common/message/SendMessageException.java
diff --git a/eiam-common/src/main/java/cn/topiam/employee/common/exception/MailProviderException.java b/eiam-common/src/main/java/cn/topiam/employee/common/exception/MailProviderException.java
index 3f5b0939..28e3593a 100644
--- a/eiam-common/src/main/java/cn/topiam/employee/common/exception/MailProviderException.java
+++ b/eiam-common/src/main/java/cn/topiam/employee/common/exception/MailProviderException.java
@@ -24,7 +24,7 @@ import org.springframework.http.HttpStatus;
import cn.topiam.employee.support.exception.TopIamException;
/**
- * 邮件服务异常
+ * 邮件提供商异常
*
* @author TopIAM
* Created by support@topiam.cn on 2020/8/19 22:53
diff --git a/eiam-common/src/main/java/cn/topiam/employee/common/exception/SmsMessageSendException.java b/eiam-common/src/main/java/cn/topiam/employee/common/exception/SmsMessageSendException.java
new file mode 100644
index 00000000..16b0281c
--- /dev/null
+++ b/eiam-common/src/main/java/cn/topiam/employee/common/exception/SmsMessageSendException.java
@@ -0,0 +1,58 @@
+/*
+ * eiam-common - Employee Identity and Access Management
+ * Copyright © 2022-Present Jinan Yuanchuang Network Technology Co., Ltd. (support@topiam.cn)
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see
Note that the detail message associated with
+ * {@code cause} is not automatically incorporated in
+ * this runtime exception's detail message.
+ *
+ * @param message the detail message (which is saved for later retrieval
+ * by the {@link #getMessage()} method).
+ * @param cause the cause (which is saved for later retrieval by the
+ * {@link #getCause()} method). (A null value is
+ * permitted, and indicates that the cause is nonexistent or
+ * unknown.)
+ * @since 1.4
+ */
+ public SmsMessageSendException(String message, Throwable cause) {
+ super(message, cause);
+ }
+}
diff --git a/eiam-common/src/main/java/cn/topiam/employee/common/message/SmsProviderException.java b/eiam-common/src/main/java/cn/topiam/employee/common/exception/SmsProviderException.java
similarity index 97%
rename from eiam-common/src/main/java/cn/topiam/employee/common/message/SmsProviderException.java
rename to eiam-common/src/main/java/cn/topiam/employee/common/exception/SmsProviderException.java
index 90efb51e..0e9eec3d 100644
--- a/eiam-common/src/main/java/cn/topiam/employee/common/message/SmsProviderException.java
+++ b/eiam-common/src/main/java/cn/topiam/employee/common/exception/SmsProviderException.java
@@ -15,7 +15,9 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see
Note that the detail message associated with
- * {@code cause} is not automatically incorporated in
- * this runtime exception's detail message.
- *
- * @param message the detail message (which is saved for later retrieval
- * by the {@link #getMessage()} method).
- * @param cause the cause (which is saved for later retrieval by the
- * {@link #getCause()} method). (A null value is
- * permitted, and indicates that the cause is nonexistent or
- * unknown.)
- * @since 1.4
- */
- public SendMessageException(String message, Throwable cause) {
- super(message, cause);
- }
-
- /**
- * Constructs a new runtime exception with the specified cause and a
- * detail message of (cause==null ? null : cause.toString())
- * (which typically contains the class and detail message of
- * cause). This constructor is useful for runtime exceptions
- * that are little more than wrappers for other throwables.
- *
- * @param cause the cause (which is saved for later retrieval by the
- * {@link #getCause()} method). (A null value is
- * permitted, and indicates that the cause is nonexistent or
- * unknown.)
- * @since 1.4
- */
- public SendMessageException(Throwable cause) {
- super(cause);
- }
-
- /**
- * Constructs a new runtime exception with the specified detail
- * message, cause, suppression enabled or disabled, and writable
- * stack trace enabled or disabled.
- *
- * @param message the detail message.
- * @param cause the cause. (A {@code null} value is permitted,
- * and indicates that the cause is nonexistent or unknown.)
- * @param enableSuppression whether or not suppression is enabled
- * or disabled
- * @param writableStackTrace whether or not the stack trace should
- * be writable
- * @since 1.7
- */
- public SendMessageException(String message, Throwable cause, boolean enableSuppression,
- boolean writableStackTrace) {
- super(message, cause, enableSuppression, writableStackTrace);
- }
-}
diff --git a/eiam-common/src/main/java/cn/topiam/employee/common/message/mail/DefaultMailProviderSendImpl.java b/eiam-common/src/main/java/cn/topiam/employee/common/message/mail/DefaultMailProviderSendImpl.java
index 8af0d25d..f5c58e21 100644
--- a/eiam-common/src/main/java/cn/topiam/employee/common/message/mail/DefaultMailProviderSendImpl.java
+++ b/eiam-common/src/main/java/cn/topiam/employee/common/message/mail/DefaultMailProviderSendImpl.java
@@ -27,10 +27,9 @@ import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.mail.javamail.JavaMailSenderImpl;
import org.springframework.mail.javamail.MimeMessageHelper;
-import cn.topiam.employee.common.message.SendMessageException;
+import cn.topiam.employee.common.exception.MailMessageSendException;
import cn.topiam.employee.common.message.enums.MailProvider;
import cn.topiam.employee.common.message.enums.MailSafetyType;
-import cn.topiam.employee.common.message.enums.MessageType;
import jakarta.mail.internet.MimeMessage;
import static org.apache.commons.codec.CharEncoding.UTF_8;
@@ -120,7 +119,7 @@ public class DefaultMailProviderSendImpl implements MailProviderSend {
taskExecutor.execute(() -> javaMailSender.send(mimeMessage));
} catch (Exception e) {
log.info("发送邮件消息失败: {}", e.getMessage());
- throw new SendMessageException(MessageType.MAIL, e.getMessage());
+ throw new MailMessageSendException(e.getMessage(), e);
}
}
diff --git a/eiam-core/src/main/java/cn/topiam/employee/core/mq/AbstractMessageListener.java b/eiam-core/src/main/java/cn/topiam/employee/core/mq/AbstractMessageListener.java
index 209b9327..3993a515 100644
--- a/eiam-core/src/main/java/cn/topiam/employee/core/mq/AbstractMessageListener.java
+++ b/eiam-core/src/main/java/cn/topiam/employee/core/mq/AbstractMessageListener.java
@@ -17,6 +17,7 @@
*/
package cn.topiam.employee.core.mq;
+import java.io.IOException;
import java.util.Map;
import org.springframework.amqp.core.Message;
@@ -50,7 +51,7 @@ public abstract class AbstractMessageListener {
* @param headers {@link Map}
*/
public void onMessage(Message message, Channel channel, @Payload String body,
- @Headers Map