Commit 5d58037d05ccf8623cba01a5b539d69bd00cabeb
1 parent
1274f925
优化:将 hutool-all 6.0 版本替换成 hutool-extra,减少依赖
Showing
7 changed files
with
20 additions
and
35 deletions
yudao-dependencies/pom.xml
| @@ -443,7 +443,7 @@ | @@ -443,7 +443,7 @@ | ||
| 443 | </dependency> | 443 | </dependency> |
| 444 | <dependency> | 444 | <dependency> |
| 445 | <groupId>org.dromara.hutool</groupId> | 445 | <groupId>org.dromara.hutool</groupId> |
| 446 | - <artifactId>hutool-all</artifactId> | 446 | + <artifactId>hutool-extra</artifactId> |
| 447 | <version>${hutool-6.version}</version> | 447 | <version>${hutool-6.version}</version> |
| 448 | </dependency> | 448 | </dependency> |
| 449 | 449 |
yudao-framework/yudao-common/pom.xml
| @@ -127,10 +127,6 @@ | @@ -127,10 +127,6 @@ | ||
| 127 | <groupId>cn.hutool</groupId> | 127 | <groupId>cn.hutool</groupId> |
| 128 | <artifactId>hutool-all</artifactId> | 128 | <artifactId>hutool-all</artifactId> |
| 129 | </dependency> | 129 | </dependency> |
| 130 | - <dependency> | ||
| 131 | - <groupId>org.dromara.hutool</groupId> | ||
| 132 | - <artifactId>hutool-all</artifactId> | ||
| 133 | - </dependency> | ||
| 134 | 130 | ||
| 135 | <dependency> | 131 | <dependency> |
| 136 | <groupId>com.alibaba</groupId> | 132 | <groupId>com.alibaba</groupId> |
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/strategy/BpmTaskCandidateExpressionStrategy.java
| 1 | package cn.iocoder.yudao.module.bpm.framework.flowable.core.candidate.strategy; | 1 | package cn.iocoder.yudao.module.bpm.framework.flowable.core.candidate.strategy; |
| 2 | 2 | ||
| 3 | -import cn.iocoder.yudao.module.bpm.framework.flowable.core.util.FlowableUtils; | 3 | +import cn.hutool.core.convert.Convert; |
| 4 | import cn.iocoder.yudao.module.bpm.framework.flowable.core.candidate.BpmTaskCandidateStrategy; | 4 | import cn.iocoder.yudao.module.bpm.framework.flowable.core.candidate.BpmTaskCandidateStrategy; |
| 5 | import cn.iocoder.yudao.module.bpm.framework.flowable.core.enums.BpmTaskCandidateStrategyEnum; | 5 | import cn.iocoder.yudao.module.bpm.framework.flowable.core.enums.BpmTaskCandidateStrategyEnum; |
| 6 | -import org.dromara.hutool.core.convert.Convert; | 6 | +import cn.iocoder.yudao.module.bpm.framework.flowable.core.util.FlowableUtils; |
| 7 | import org.flowable.engine.delegate.DelegateExecution; | 7 | import org.flowable.engine.delegate.DelegateExecution; |
| 8 | import org.springframework.stereotype.Component; | 8 | import org.springframework.stereotype.Component; |
| 9 | 9 |
yudao-module-system/yudao-module-system-biz/pom.xml
| @@ -127,6 +127,12 @@ | @@ -127,6 +127,12 @@ | ||
| 127 | <groupId>com.xingyuv</groupId> | 127 | <groupId>com.xingyuv</groupId> |
| 128 | <artifactId>spring-boot-starter-captcha-plus</artifactId> <!-- 验证码,一般用于登录使用 --> | 128 | <artifactId>spring-boot-starter-captcha-plus</artifactId> <!-- 验证码,一般用于登录使用 --> |
| 129 | </dependency> | 129 | </dependency> |
| 130 | + | ||
| 131 | + <dependency> | ||
| 132 | + <groupId>org.dromara.hutool</groupId> | ||
| 133 | + <artifactId>hutool-extra</artifactId> <!-- 邮件 --> | ||
| 134 | + </dependency> | ||
| 135 | + | ||
| 130 | </dependencies> | 136 | </dependencies> |
| 131 | 137 | ||
| 132 | </project> | 138 | </project> |
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/convert/mail/MailAccountConvert.java deleted
| 1 | -package cn.iocoder.yudao.module.system.convert.mail; | ||
| 2 | - | ||
| 3 | -import cn.hutool.core.util.StrUtil; | ||
| 4 | -import cn.iocoder.yudao.module.system.dal.dataobject.mail.MailAccountDO; | ||
| 5 | -import org.dromara.hutool.extra.mail.MailAccount; | ||
| 6 | -import org.mapstruct.Mapper; | ||
| 7 | -import org.mapstruct.factory.Mappers; | ||
| 8 | - | ||
| 9 | -@Mapper | ||
| 10 | -public interface MailAccountConvert { | ||
| 11 | - | ||
| 12 | - MailAccountConvert INSTANCE = Mappers.getMapper(MailAccountConvert.class); | ||
| 13 | - | ||
| 14 | - default MailAccount convert(MailAccountDO account, String nickname) { | ||
| 15 | - String from = StrUtil.isNotEmpty(nickname) ? nickname + " <" + account.getMail() + ">" : account.getMail(); | ||
| 16 | - return new MailAccount().setFrom(from).setAuth(true) | ||
| 17 | - .setUser(account.getUsername()).setPass(account.getPassword().toCharArray()) | ||
| 18 | - .setHost(account.getHost()).setPort(account.getPort()).setSslEnable(account.getSslEnable()); | ||
| 19 | - } | ||
| 20 | - | ||
| 21 | -} |
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; | @@ -3,7 +3,6 @@ package cn.iocoder.yudao.module.system.service.mail; | ||
| 3 | import cn.hutool.core.util.StrUtil; | 3 | import cn.hutool.core.util.StrUtil; |
| 4 | import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; | 4 | import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; |
| 5 | import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; | 5 | import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; |
| 6 | -import cn.iocoder.yudao.module.system.convert.mail.MailAccountConvert; | ||
| 7 | import cn.iocoder.yudao.module.system.dal.dataobject.mail.MailAccountDO; | 6 | import cn.iocoder.yudao.module.system.dal.dataobject.mail.MailAccountDO; |
| 8 | import cn.iocoder.yudao.module.system.dal.dataobject.mail.MailTemplateDO; | 7 | import cn.iocoder.yudao.module.system.dal.dataobject.mail.MailTemplateDO; |
| 9 | import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO; | 8 | import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO; |
| @@ -12,13 +11,12 @@ import cn.iocoder.yudao.module.system.mq.producer.mail.MailProducer; | @@ -12,13 +11,12 @@ import cn.iocoder.yudao.module.system.mq.producer.mail.MailProducer; | ||
| 12 | import cn.iocoder.yudao.module.system.service.member.MemberService; | 11 | import cn.iocoder.yudao.module.system.service.member.MemberService; |
| 13 | import cn.iocoder.yudao.module.system.service.user.AdminUserService; | 12 | import cn.iocoder.yudao.module.system.service.user.AdminUserService; |
| 14 | import com.google.common.annotations.VisibleForTesting; | 13 | import com.google.common.annotations.VisibleForTesting; |
| 14 | +import jakarta.annotation.Resource; | ||
| 15 | import lombok.extern.slf4j.Slf4j; | 15 | import lombok.extern.slf4j.Slf4j; |
| 16 | -import org.dromara.hutool.extra.mail.MailAccount; | ||
| 17 | -import org.dromara.hutool.extra.mail.MailUtil; | 16 | +import org.dromara.hutool.extra.mail.*; |
| 18 | import org.springframework.stereotype.Service; | 17 | import org.springframework.stereotype.Service; |
| 19 | import org.springframework.validation.annotation.Validated; | 18 | import org.springframework.validation.annotation.Validated; |
| 20 | 19 | ||
| 21 | -import jakarta.annotation.Resource; | ||
| 22 | import java.util.Map; | 20 | import java.util.Map; |
| 23 | 21 | ||
| 24 | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; | 22 | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; |
| @@ -105,7 +103,7 @@ public class MailSendServiceImpl implements MailSendService { | @@ -105,7 +103,7 @@ public class MailSendServiceImpl implements MailSendService { | ||
| 105 | public void doSendMail(MailSendMessage message) { | 103 | public void doSendMail(MailSendMessage message) { |
| 106 | // 1. 创建发送账号 | 104 | // 1. 创建发送账号 |
| 107 | MailAccountDO account = validateMailAccount(message.getAccountId()); | 105 | MailAccountDO account = validateMailAccount(message.getAccountId()); |
| 108 | - MailAccount mailAccount = MailAccountConvert.INSTANCE.convert(account, message.getNickname()); | 106 | + MailAccount mailAccount = buildMailAccount(account, message.getNickname()); |
| 109 | // 2. 发送邮件 | 107 | // 2. 发送邮件 |
| 110 | try { | 108 | try { |
| 111 | String messageId = MailUtil.send(mailAccount, message.getMail(), | 109 | String messageId = MailUtil.send(mailAccount, message.getMail(), |
| @@ -118,6 +116,13 @@ public class MailSendServiceImpl implements MailSendService { | @@ -118,6 +116,13 @@ public class MailSendServiceImpl implements MailSendService { | ||
| 118 | } | 116 | } |
| 119 | } | 117 | } |
| 120 | 118 | ||
| 119 | + private MailAccount buildMailAccount(MailAccountDO account, String nickname) { | ||
| 120 | + String from = StrUtil.isNotEmpty(nickname) ? nickname + " <" + account.getMail() + ">" : account.getMail(); | ||
| 121 | + return new MailAccount().setFrom(from).setAuth(true) | ||
| 122 | + .setUser(account.getUsername()).setPass(account.getPassword().toCharArray()) | ||
| 123 | + .setHost(account.getHost()).setPort(account.getPort()).setSslEnable(account.getSslEnable()); | ||
| 124 | + } | ||
| 125 | + | ||
| 121 | @VisibleForTesting | 126 | @VisibleForTesting |
| 122 | MailTemplateDO validateMailTemplate(String templateCode) { | 127 | MailTemplateDO validateMailTemplate(String templateCode) { |
| 123 | // 获得邮件模板。考虑到效率,从缓存中获取 | 128 | // 获得邮件模板。考虑到效率,从缓存中获取 |
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; | @@ -13,8 +13,7 @@ import cn.iocoder.yudao.module.system.mq.producer.mail.MailProducer; | ||
| 13 | import cn.iocoder.yudao.module.system.service.member.MemberService; | 13 | import cn.iocoder.yudao.module.system.service.member.MemberService; |
| 14 | import cn.iocoder.yudao.module.system.service.user.AdminUserService; | 14 | import cn.iocoder.yudao.module.system.service.user.AdminUserService; |
| 15 | import org.assertj.core.util.Lists; | 15 | import org.assertj.core.util.Lists; |
| 16 | -import org.dromara.hutool.extra.mail.MailAccount; | ||
| 17 | -import org.dromara.hutool.extra.mail.MailUtil; | 16 | +import org.dromara.hutool.extra.mail.*; |
| 18 | import org.junit.jupiter.api.Disabled; | 17 | import org.junit.jupiter.api.Disabled; |
| 19 | import org.junit.jupiter.api.Test; | 18 | import org.junit.jupiter.api.Test; |
| 20 | import org.mockito.InjectMocks; | 19 | import org.mockito.InjectMocks; |