Browse Source

优化:将 hutool-all 6.0 版本替换成 hutool-extra,减少依赖

YunaiV 10 months ago
parent
commit
5d58037d05

+ 1 - 1
yudao-dependencies/pom.xml

@@ -443,7 +443,7 @@
             </dependency>
             <dependency>
                 <groupId>org.dromara.hutool</groupId>
-                <artifactId>hutool-all</artifactId>
+                <artifactId>hutool-extra</artifactId>
                 <version>${hutool-6.version}</version>
             </dependency>
 

+ 0 - 4
yudao-framework/yudao-common/pom.xml

@@ -127,10 +127,6 @@
             <groupId>cn.hutool</groupId>
             <artifactId>hutool-all</artifactId>
         </dependency>
-        <dependency>
-            <groupId>org.dromara.hutool</groupId>
-            <artifactId>hutool-all</artifactId>
-        </dependency>
 
         <dependency>
             <groupId>com.alibaba</groupId>

+ 2 - 2
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/strategy/BpmTaskCandidateExpressionStrategy.java

@@ -1,9 +1,9 @@
 package cn.iocoder.yudao.module.bpm.framework.flowable.core.candidate.strategy;
 
-import cn.iocoder.yudao.module.bpm.framework.flowable.core.util.FlowableUtils;
+import cn.hutool.core.convert.Convert;
 import cn.iocoder.yudao.module.bpm.framework.flowable.core.candidate.BpmTaskCandidateStrategy;
 import cn.iocoder.yudao.module.bpm.framework.flowable.core.enums.BpmTaskCandidateStrategyEnum;
-import org.dromara.hutool.core.convert.Convert;
+import cn.iocoder.yudao.module.bpm.framework.flowable.core.util.FlowableUtils;
 import org.flowable.engine.delegate.DelegateExecution;
 import org.springframework.stereotype.Component;
 

+ 6 - 0
yudao-module-system/yudao-module-system-biz/pom.xml

@@ -127,6 +127,12 @@
             <groupId>com.xingyuv</groupId>
             <artifactId>spring-boot-starter-captcha-plus</artifactId> <!-- 验证码,一般用于登录使用 -->
         </dependency>
+
+        <dependency>
+            <groupId>org.dromara.hutool</groupId>
+            <artifactId>hutool-extra</artifactId> <!-- 邮件 -->
+        </dependency>
+
     </dependencies>
 
 </project>

+ 0 - 21
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/convert/mail/MailAccountConvert.java

@@ -1,21 +0,0 @@
-package cn.iocoder.yudao.module.system.convert.mail;
-
-import cn.hutool.core.util.StrUtil;
-import cn.iocoder.yudao.module.system.dal.dataobject.mail.MailAccountDO;
-import org.dromara.hutool.extra.mail.MailAccount;
-import org.mapstruct.Mapper;
-import org.mapstruct.factory.Mappers;
-
-@Mapper
-public interface MailAccountConvert {
-
-    MailAccountConvert INSTANCE = Mappers.getMapper(MailAccountConvert.class);
-
-    default MailAccount convert(MailAccountDO account, String nickname) {
-        String from = StrUtil.isNotEmpty(nickname) ? nickname + " <" + account.getMail() + ">" : account.getMail();
-        return new MailAccount().setFrom(from).setAuth(true)
-                .setUser(account.getUsername()).setPass(account.getPassword().toCharArray())
-                .setHost(account.getHost()).setPort(account.getPort()).setSslEnable(account.getSslEnable());
-    }
-
-}

+ 10 - 5
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/mail/MailSendServiceImpl.java

@@ -3,7 +3,6 @@ package cn.iocoder.yudao.module.system.service.mail;
 import cn.hutool.core.util.StrUtil;
 import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
 import cn.iocoder.yudao.framework.common.enums.UserTypeEnum;
-import cn.iocoder.yudao.module.system.convert.mail.MailAccountConvert;
 import cn.iocoder.yudao.module.system.dal.dataobject.mail.MailAccountDO;
 import cn.iocoder.yudao.module.system.dal.dataobject.mail.MailTemplateDO;
 import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO;
@@ -12,13 +11,12 @@ import cn.iocoder.yudao.module.system.mq.producer.mail.MailProducer;
 import cn.iocoder.yudao.module.system.service.member.MemberService;
 import cn.iocoder.yudao.module.system.service.user.AdminUserService;
 import com.google.common.annotations.VisibleForTesting;
+import jakarta.annotation.Resource;
 import lombok.extern.slf4j.Slf4j;
-import org.dromara.hutool.extra.mail.MailAccount;
-import org.dromara.hutool.extra.mail.MailUtil;
+import org.dromara.hutool.extra.mail.*;
 import org.springframework.stereotype.Service;
 import org.springframework.validation.annotation.Validated;
 
-import jakarta.annotation.Resource;
 import java.util.Map;
 
 import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
@@ -105,7 +103,7 @@ public class MailSendServiceImpl implements MailSendService {
     public void doSendMail(MailSendMessage message) {
         // 1. 创建发送账号
         MailAccountDO account = validateMailAccount(message.getAccountId());
-        MailAccount mailAccount  = MailAccountConvert.INSTANCE.convert(account, message.getNickname());
+        MailAccount mailAccount  = buildMailAccount(account, message.getNickname());
         // 2. 发送邮件
         try {
             String messageId = MailUtil.send(mailAccount, message.getMail(),
@@ -118,6 +116,13 @@ public class MailSendServiceImpl implements MailSendService {
         }
     }
 
+    private MailAccount buildMailAccount(MailAccountDO account, String nickname) {
+        String from = StrUtil.isNotEmpty(nickname) ? nickname + " <" + account.getMail() + ">" : account.getMail();
+        return new MailAccount().setFrom(from).setAuth(true)
+                .setUser(account.getUsername()).setPass(account.getPassword().toCharArray())
+                .setHost(account.getHost()).setPort(account.getPort()).setSslEnable(account.getSslEnable());
+    }
+
     @VisibleForTesting
     MailTemplateDO validateMailTemplate(String templateCode) {
         // 获得邮件模板。考虑到效率,从缓存中获取

+ 1 - 2
yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/mail/MailSendServiceImplTest.java

@@ -13,8 +13,7 @@ import cn.iocoder.yudao.module.system.mq.producer.mail.MailProducer;
 import cn.iocoder.yudao.module.system.service.member.MemberService;
 import cn.iocoder.yudao.module.system.service.user.AdminUserService;
 import org.assertj.core.util.Lists;
-import org.dromara.hutool.extra.mail.MailAccount;
-import org.dromara.hutool.extra.mail.MailUtil;
+import org.dromara.hutool.extra.mail.*;
 import org.junit.jupiter.api.Disabled;
 import org.junit.jupiter.api.Test;
 import org.mockito.InjectMocks;