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
yudao-framework/yudao-common/pom.xml
| ... | ... | @@ -127,10 +127,6 @@ |
| 127 | 127 | <groupId>cn.hutool</groupId> |
| 128 | 128 | <artifactId>hutool-all</artifactId> |
| 129 | 129 | </dependency> |
| 130 | - <dependency> | |
| 131 | - <groupId>org.dromara.hutool</groupId> | |
| 132 | - <artifactId>hutool-all</artifactId> | |
| 133 | - </dependency> | |
| 134 | 130 | |
| 135 | 131 | <dependency> |
| 136 | 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 | 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 | 4 | import cn.iocoder.yudao.module.bpm.framework.flowable.core.candidate.BpmTaskCandidateStrategy; |
| 5 | 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 | 7 | import org.flowable.engine.delegate.DelegateExecution; |
| 8 | 8 | import org.springframework.stereotype.Component; |
| 9 | 9 | ... | ... |
yudao-module-system/yudao-module-system-biz/pom.xml
| ... | ... | @@ -127,6 +127,12 @@ |
| 127 | 127 | <groupId>com.xingyuv</groupId> |
| 128 | 128 | <artifactId>spring-boot-starter-captcha-plus</artifactId> <!-- 验证码,一般用于登录使用 --> |
| 129 | 129 | </dependency> |
| 130 | + | |
| 131 | + <dependency> | |
| 132 | + <groupId>org.dromara.hutool</groupId> | |
| 133 | + <artifactId>hutool-extra</artifactId> <!-- 邮件 --> | |
| 134 | + </dependency> | |
| 135 | + | |
| 130 | 136 | </dependencies> |
| 131 | 137 | |
| 132 | 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 | 3 | import cn.hutool.core.util.StrUtil; |
| 4 | 4 | import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; |
| 5 | 5 | import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; |
| 6 | -import cn.iocoder.yudao.module.system.convert.mail.MailAccountConvert; | |
| 7 | 6 | import cn.iocoder.yudao.module.system.dal.dataobject.mail.MailAccountDO; |
| 8 | 7 | import cn.iocoder.yudao.module.system.dal.dataobject.mail.MailTemplateDO; |
| 9 | 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 | 11 | import cn.iocoder.yudao.module.system.service.member.MemberService; |
| 13 | 12 | import cn.iocoder.yudao.module.system.service.user.AdminUserService; |
| 14 | 13 | import com.google.common.annotations.VisibleForTesting; |
| 14 | +import jakarta.annotation.Resource; | |
| 15 | 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 | 17 | import org.springframework.stereotype.Service; |
| 19 | 18 | import org.springframework.validation.annotation.Validated; |
| 20 | 19 | |
| 21 | -import jakarta.annotation.Resource; | |
| 22 | 20 | import java.util.Map; |
| 23 | 21 | |
| 24 | 22 | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; |
| ... | ... | @@ -105,7 +103,7 @@ public class MailSendServiceImpl implements MailSendService { |
| 105 | 103 | public void doSendMail(MailSendMessage message) { |
| 106 | 104 | // 1. 创建发送账号 |
| 107 | 105 | MailAccountDO account = validateMailAccount(message.getAccountId()); |
| 108 | - MailAccount mailAccount = MailAccountConvert.INSTANCE.convert(account, message.getNickname()); | |
| 106 | + MailAccount mailAccount = buildMailAccount(account, message.getNickname()); | |
| 109 | 107 | // 2. 发送邮件 |
| 110 | 108 | try { |
| 111 | 109 | String messageId = MailUtil.send(mailAccount, message.getMail(), |
| ... | ... | @@ -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 | 126 | @VisibleForTesting |
| 122 | 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 | 13 | import cn.iocoder.yudao.module.system.service.member.MemberService; |
| 14 | 14 | import cn.iocoder.yudao.module.system.service.user.AdminUserService; |
| 15 | 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 | 17 | import org.junit.jupiter.api.Disabled; |
| 19 | 18 | import org.junit.jupiter.api.Test; |
| 20 | 19 | import org.mockito.InjectMocks; | ... | ... |