优化:将 hutool-all 6.0 版本替换成 hutool-extra,减少依赖
This commit is contained in:
parent
6c3f88bacd
commit
24dacacf15
@ -11,12 +11,13 @@ import cn.iocoder.yudao.module.infra.controller.admin.job.vo.job.JobSaveReqVO;
|
|||||||
import cn.iocoder.yudao.module.infra.dal.dataobject.job.JobDO;
|
import cn.iocoder.yudao.module.infra.dal.dataobject.job.JobDO;
|
||||||
import cn.iocoder.yudao.module.infra.dal.mysql.job.JobMapper;
|
import cn.iocoder.yudao.module.infra.dal.mysql.job.JobMapper;
|
||||||
import cn.iocoder.yudao.module.infra.enums.job.JobStatusEnum;
|
import cn.iocoder.yudao.module.infra.enums.job.JobStatusEnum;
|
||||||
import jakarta.annotation.Resource;
|
|
||||||
import org.quartz.SchedulerException;
|
import org.quartz.SchedulerException;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.containsAny;
|
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.containsAny;
|
||||||
import static cn.iocoder.yudao.module.infra.enums.ErrorCodeConstants.*;
|
import static cn.iocoder.yudao.module.infra.enums.ErrorCodeConstants.*;
|
||||||
|
@ -127,12 +127,6 @@
|
|||||||
<groupId>com.xingyuv</groupId>
|
<groupId>com.xingyuv</groupId>
|
||||||
<artifactId>spring-boot-starter-captcha-plus</artifactId> <!-- 验证码,一般用于登录使用 -->
|
<artifactId>spring-boot-starter-captcha-plus</artifactId> <!-- 验证码,一般用于登录使用 -->
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.dromara.hutool</groupId>
|
|
||||||
<artifactId>hutool-extra</artifactId> <!-- 邮件 -->
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package cn.iocoder.yudao.module.system.service.mail;
|
package cn.iocoder.yudao.module.system.service.mail;
|
||||||
|
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import cn.hutool.extra.mail.*;
|
||||||
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
|
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
|
||||||
import cn.iocoder.yudao.framework.common.enums.UserTypeEnum;
|
import cn.iocoder.yudao.framework.common.enums.UserTypeEnum;
|
||||||
import cn.iocoder.yudao.module.system.dal.dataobject.mail.MailAccountDO;
|
import cn.iocoder.yudao.module.system.dal.dataobject.mail.MailAccountDO;
|
||||||
@ -11,12 +12,11 @@ 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.member.MemberService;
|
||||||
import cn.iocoder.yudao.module.system.service.user.AdminUserService;
|
import cn.iocoder.yudao.module.system.service.user.AdminUserService;
|
||||||
import com.google.common.annotations.VisibleForTesting;
|
import com.google.common.annotations.VisibleForTesting;
|
||||||
import jakarta.annotation.Resource;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.dromara.hutool.extra.mail.*;
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||||
@ -119,7 +119,7 @@ public class MailSendServiceImpl implements MailSendService {
|
|||||||
private MailAccount buildMailAccount(MailAccountDO account, String nickname) {
|
private MailAccount buildMailAccount(MailAccountDO account, String nickname) {
|
||||||
String from = StrUtil.isNotEmpty(nickname) ? nickname + " <" + account.getMail() + ">" : account.getMail();
|
String from = StrUtil.isNotEmpty(nickname) ? nickname + " <" + account.getMail() + ">" : account.getMail();
|
||||||
return new MailAccount().setFrom(from).setAuth(true)
|
return new MailAccount().setFrom(from).setAuth(true)
|
||||||
.setUser(account.getUsername()).setPass(account.getPassword().toCharArray())
|
.setUser(account.getUsername()).setPass(account.getPassword())
|
||||||
.setHost(account.getHost()).setPort(account.getPort()).setSslEnable(account.getSslEnable());
|
.setHost(account.getHost()).setPort(account.getPort()).setSslEnable(account.getSslEnable());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package cn.iocoder.yudao.module.system.service.mail;
|
package cn.iocoder.yudao.module.system.service.mail;
|
||||||
|
|
||||||
import cn.hutool.core.map.MapUtil;
|
import cn.hutool.core.map.MapUtil;
|
||||||
|
import cn.hutool.extra.mail.*;
|
||||||
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
|
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
|
||||||
import cn.iocoder.yudao.framework.common.enums.UserTypeEnum;
|
import cn.iocoder.yudao.framework.common.enums.UserTypeEnum;
|
||||||
import cn.iocoder.yudao.framework.test.core.ut.BaseMockitoUnitTest;
|
import cn.iocoder.yudao.framework.test.core.ut.BaseMockitoUnitTest;
|
||||||
@ -13,7 +14,6 @@ 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.member.MemberService;
|
||||||
import cn.iocoder.yudao.module.system.service.user.AdminUserService;
|
import cn.iocoder.yudao.module.system.service.user.AdminUserService;
|
||||||
import org.assertj.core.util.Lists;
|
import org.assertj.core.util.Lists;
|
||||||
import org.dromara.hutool.extra.mail.*;
|
|
||||||
import org.junit.jupiter.api.Disabled;
|
import org.junit.jupiter.api.Disabled;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.mockito.InjectMocks;
|
import org.mockito.InjectMocks;
|
||||||
@ -59,7 +59,7 @@ public class MailSendServiceImplTest extends BaseMockitoUnitTest {
|
|||||||
// .setFrom("奥特曼 <ydym_test@163.com>")
|
// .setFrom("奥特曼 <ydym_test@163.com>")
|
||||||
.setFrom("ydym_test@163.com") // 邮箱地址
|
.setFrom("ydym_test@163.com") // 邮箱地址
|
||||||
.setHost("smtp.163.com").setPort(465).setSslEnable(true) // SMTP 服务器
|
.setHost("smtp.163.com").setPort(465).setSslEnable(true) // SMTP 服务器
|
||||||
.setAuth(true).setUser("ydym_test@163.com").setPass("WBZTEINMIFVRYSOE".toCharArray()); // 登录账号密码
|
.setAuth(true).setUser("ydym_test@163.com").setPass("WBZTEINMIFVRYSOE"); // 登录账号密码
|
||||||
String messageId = MailUtil.send(mailAccount, "7685413@qq.com", "主题", "内容", false);
|
String messageId = MailUtil.send(mailAccount, "7685413@qq.com", "主题", "内容", false);
|
||||||
System.out.println("发送结果:" + messageId);
|
System.out.println("发送结果:" + messageId);
|
||||||
}
|
}
|
||||||
@ -281,7 +281,7 @@ public class MailSendServiceImplTest extends BaseMockitoUnitTest {
|
|||||||
assertEquals("芋艿 <7685@qq.com>", mailAccount.getFrom());
|
assertEquals("芋艿 <7685@qq.com>", mailAccount.getFrom());
|
||||||
assertTrue(mailAccount.isAuth());
|
assertTrue(mailAccount.isAuth());
|
||||||
assertEquals(account.getUsername(), mailAccount.getUser());
|
assertEquals(account.getUsername(), mailAccount.getUser());
|
||||||
assertArrayEquals(account.getPassword().toCharArray(), mailAccount.getPass());
|
assertEquals(account.getPassword(), mailAccount.getPass());
|
||||||
assertEquals(account.getHost(), mailAccount.getHost());
|
assertEquals(account.getHost(), mailAccount.getHost());
|
||||||
assertEquals(account.getPort(), mailAccount.getPort());
|
assertEquals(account.getPort(), mailAccount.getPort());
|
||||||
assertEquals(account.getSslEnable(), mailAccount.isSslEnable());
|
assertEquals(account.getSslEnable(), mailAccount.isSslEnable());
|
||||||
@ -312,7 +312,7 @@ public class MailSendServiceImplTest extends BaseMockitoUnitTest {
|
|||||||
assertEquals("芋艿 <7685@qq.com>", mailAccount.getFrom());
|
assertEquals("芋艿 <7685@qq.com>", mailAccount.getFrom());
|
||||||
assertTrue(mailAccount.isAuth());
|
assertTrue(mailAccount.isAuth());
|
||||||
assertEquals(account.getUsername(), mailAccount.getUser());
|
assertEquals(account.getUsername(), mailAccount.getUser());
|
||||||
assertArrayEquals(account.getPassword().toCharArray(), mailAccount.getPass());
|
assertEquals(account.getPassword(), mailAccount.getPass());
|
||||||
assertEquals(account.getHost(), mailAccount.getHost());
|
assertEquals(account.getHost(), mailAccount.getHost());
|
||||||
assertEquals(account.getPort(), mailAccount.getPort());
|
assertEquals(account.getPort(), mailAccount.getPort());
|
||||||
assertEquals(account.getSslEnable(), mailAccount.isSslEnable());
|
assertEquals(account.getSslEnable(), mailAccount.isSslEnable());
|
||||||
|
Loading…
Reference in New Issue
Block a user