From 8a555eb191593edcc6d7126c47ffcd3007da33ad Mon Sep 17 00:00:00 2001 From: bleachtred Date: Fri, 14 Apr 2023 14:11:28 +0800 Subject: [PATCH] =?UTF-8?q?update=20=E4=BC=98=E5=8C=96=20=E5=8E=BB?= =?UTF-8?q?=E9=99=A4=E5=A4=9A=E4=BD=99=E7=9A=84=E5=BC=95=E7=94=A8=E5=89=8D?= =?UTF-8?q?=E7=BC=80&&=E6=B6=88=E9=99=A4serialVersionUID=E8=AD=A6=E5=91=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../org/dromara/common/mail/utils/Mail.java | 18 ++++++++---------- .../dromara/common/mail/utils/MailAccount.java | 4 +++- .../common/mail/utils/MailException.java | 5 ++++- .../dromara/common/mail/utils/MailUtils.java | 2 +- 4 files changed, 16 insertions(+), 13 deletions(-) diff --git a/ruoyi-common/ruoyi-common-mail/src/main/java/org/dromara/common/mail/utils/Mail.java b/ruoyi-common/ruoyi-common-mail/src/main/java/org/dromara/common/mail/utils/Mail.java index 1b01d28f..17459d34 100644 --- a/ruoyi-common/ruoyi-common-mail/src/main/java/org/dromara/common/mail/utils/Mail.java +++ b/ruoyi-common/ruoyi-common-mail/src/main/java/org/dromara/common/mail/utils/Mail.java @@ -18,10 +18,7 @@ import jakarta.mail.internet.MimeMultipart; import jakarta.mail.internet.MimeUtility; import jakarta.mail.util.ByteArrayDataSource; -import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.io.PrintStream; +import java.io.*; import java.nio.charset.Charset; import java.util.Date; @@ -32,7 +29,8 @@ import java.util.Date; * @since 3.2.0 */ public class Mail implements Builder { - private static final long serialVersionUID = 1L; + @Serial + private static final long serialVersionUID = 1L; /** * 邮箱帐户信息以及一些客户端配置信息 @@ -261,7 +259,7 @@ public class Mail implements Builder { bodyPart.setDataHandler(new DataHandler(attachment)); nameEncoded = attachment.getName(); if (this.mailAccount.isEncodefilename()) { - nameEncoded = org.dromara.common.mail.utils.InternalMailUtil.encodeText(nameEncoded, charset); + nameEncoded = InternalMailUtil.encodeText(nameEncoded, charset); } // 普通附件文件名 bodyPart.setFileName(nameEncoded); @@ -423,7 +421,7 @@ public class Mail implements Builder { // 用户未提供发送方,则从Session中自动获取 msg.setFrom(); } else { - msg.setFrom(org.dromara.common.mail.utils.InternalMailUtil.parseFirstAddress(from, charset)); + msg.setFrom(InternalMailUtil.parseFirstAddress(from, charset)); } // 标题 msg.setSubject(this.title, (null == charset) ? null : charset.name()); @@ -432,14 +430,14 @@ public class Mail implements Builder { // 内容和附件 msg.setContent(buildContent(charset)); // 收件人 - msg.setRecipients(MimeMessage.RecipientType.TO, org.dromara.common.mail.utils.InternalMailUtil.parseAddressFromStrs(this.tos, charset)); + msg.setRecipients(MimeMessage.RecipientType.TO, InternalMailUtil.parseAddressFromStrs(this.tos, charset)); // 抄送人 if (ArrayUtil.isNotEmpty(this.ccs)) { - msg.setRecipients(MimeMessage.RecipientType.CC, org.dromara.common.mail.utils.InternalMailUtil.parseAddressFromStrs(this.ccs, charset)); + msg.setRecipients(MimeMessage.RecipientType.CC, InternalMailUtil.parseAddressFromStrs(this.ccs, charset)); } // 密送人 if (ArrayUtil.isNotEmpty(this.bccs)) { - msg.setRecipients(MimeMessage.RecipientType.BCC, org.dromara.common.mail.utils.InternalMailUtil.parseAddressFromStrs(this.bccs, charset)); + msg.setRecipients(MimeMessage.RecipientType.BCC, InternalMailUtil.parseAddressFromStrs(this.bccs, charset)); } // 回复地址(reply-to) if (ArrayUtil.isNotEmpty(this.reply)) { diff --git a/ruoyi-common/ruoyi-common-mail/src/main/java/org/dromara/common/mail/utils/MailAccount.java b/ruoyi-common/ruoyi-common-mail/src/main/java/org/dromara/common/mail/utils/MailAccount.java index 5492bd2e..d2b9e2c0 100644 --- a/ruoyi-common/ruoyi-common-mail/src/main/java/org/dromara/common/mail/utils/MailAccount.java +++ b/ruoyi-common/ruoyi-common-mail/src/main/java/org/dromara/common/mail/utils/MailAccount.java @@ -5,6 +5,7 @@ import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; import cn.hutool.setting.Setting; +import java.io.Serial; import java.io.Serializable; import java.nio.charset.Charset; import java.util.HashMap; @@ -17,7 +18,8 @@ import java.util.Properties; * @author Luxiaolei */ public class MailAccount implements Serializable { - private static final long serialVersionUID = -6937313421815719204L; + @Serial + private static final long serialVersionUID = -6937313421815719204L; private static final String MAIL_PROTOCOL = "mail.transport.protocol"; private static final String SMTP_HOST = "mail.smtp.host"; diff --git a/ruoyi-common/ruoyi-common-mail/src/main/java/org/dromara/common/mail/utils/MailException.java b/ruoyi-common/ruoyi-common-mail/src/main/java/org/dromara/common/mail/utils/MailException.java index 82e65099..ced09a29 100644 --- a/ruoyi-common/ruoyi-common-mail/src/main/java/org/dromara/common/mail/utils/MailException.java +++ b/ruoyi-common/ruoyi-common-mail/src/main/java/org/dromara/common/mail/utils/MailException.java @@ -3,12 +3,15 @@ package org.dromara.common.mail.utils; import cn.hutool.core.exceptions.ExceptionUtil; import cn.hutool.core.util.StrUtil; +import java.io.Serial; + /** * 邮件异常 * @author xiaoleilu */ public class MailException extends RuntimeException{ - private static final long serialVersionUID = 8247610319171014183L; + @Serial + private static final long serialVersionUID = 8247610319171014183L; public MailException(Throwable e) { super(ExceptionUtil.getMessage(e), e); diff --git a/ruoyi-common/ruoyi-common-mail/src/main/java/org/dromara/common/mail/utils/MailUtils.java b/ruoyi-common/ruoyi-common-mail/src/main/java/org/dromara/common/mail/utils/MailUtils.java index 023be86a..0400700b 100644 --- a/ruoyi-common/ruoyi-common-mail/src/main/java/org/dromara/common/mail/utils/MailUtils.java +++ b/ruoyi-common/ruoyi-common-mail/src/main/java/org/dromara/common/mail/utils/MailUtils.java @@ -413,7 +413,7 @@ public class MailUtils { */ private static String send(MailAccount mailAccount, boolean useGlobalSession, Collection tos, Collection ccs, Collection bccs, String subject, String content, Map imageMap, boolean isHtml, File... files) { - final org.dromara.common.mail.utils.Mail mail = Mail.create(mailAccount).setUseGlobalSession(useGlobalSession); + final Mail mail = Mail.create(mailAccount).setUseGlobalSession(useGlobalSession); // 可选抄送人 if (CollUtil.isNotEmpty(ccs)) {