Commit e4326036f86657685bc357eefa1de3525c4a4def
1 parent
bd86b89e
fix 邮件发送 账号信息装载 在convert中处理
Showing
2 changed files
with
14 additions
and
8 deletions
yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/convert/mail/MailAccountConvert.java
| 1 | package cn.iocoder.yudao.module.system.convert.mail; | 1 | package cn.iocoder.yudao.module.system.convert.mail; |
| 2 | 2 | ||
| 3 | +import cn.hutool.extra.mail.MailAccount; | ||
| 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 4 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 4 | import cn.iocoder.yudao.module.system.controller.admin.mail.vo.account.MailAccountBaseVO; | 5 | import cn.iocoder.yudao.module.system.controller.admin.mail.vo.account.MailAccountBaseVO; |
| 5 | import cn.iocoder.yudao.module.system.dal.dataobject.mail.MailAccountDO; | 6 | import cn.iocoder.yudao.module.system.dal.dataobject.mail.MailAccountDO; |
| @@ -19,4 +20,15 @@ public interface MailAccountConvert { | @@ -19,4 +20,15 @@ public interface MailAccountConvert { | ||
| 19 | PageResult<MailAccountBaseVO> convertPage(PageResult<MailAccountDO> pageResult); | 20 | PageResult<MailAccountBaseVO> convertPage(PageResult<MailAccountDO> pageResult); |
| 20 | 21 | ||
| 21 | List<MailAccountBaseVO> convertList02(List<MailAccountDO> list); | 22 | List<MailAccountBaseVO> convertList02(List<MailAccountDO> list); |
| 23 | + | ||
| 24 | + default MailAccount convertAccount(MailAccountDO mailAccountDO){ | ||
| 25 | + return new MailAccount() | ||
| 26 | + .setHost(mailAccountDO.getHost()) | ||
| 27 | + .setPort(mailAccountDO.getPort()) | ||
| 28 | + .setAuth(true) | ||
| 29 | + .setFrom(mailAccountDO.getFrom()) | ||
| 30 | + .setUser(mailAccountDO.getUsername()) | ||
| 31 | + .setPass(mailAccountDO.getPassword()) | ||
| 32 | + .setSslEnable(mailAccountDO.getSslEnable()); | ||
| 33 | + }; | ||
| 22 | } | 34 | } |
yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/service/mail/impl/MailAccountServiceImpl.java
| @@ -106,14 +106,8 @@ public class MailAccountServiceImpl implements MailAccountService { | @@ -106,14 +106,8 @@ public class MailAccountServiceImpl implements MailAccountService { | ||
| 106 | //List<String> fileIds = mailSendVO.getFileIds(); | 106 | //List<String> fileIds = mailSendVO.getFileIds(); |
| 107 | 107 | ||
| 108 | //装载账号信息 | 108 | //装载账号信息 |
| 109 | - MailAccount account = new MailAccount(); | ||
| 110 | - account.setHost(mailAccountDO.getHost()); | ||
| 111 | - account.setPort(mailAccountDO.getPort()); | ||
| 112 | - account.setAuth(true); | ||
| 113 | - account.setFrom(mailAccountDO.getFrom()); | ||
| 114 | - account.setUser(mailAccountDO.getUsername()); | ||
| 115 | - account.setPass(mailAccountDO.getPassword()); | ||
| 116 | - account.setSslEnable(mailAccountDO.getSslEnable()); | 109 | + MailAccount account = MailAccountConvert.INSTANCE.convertAccount(mailAccountDO); |
| 110 | + | ||
| 117 | //发送 | 111 | //发送 |
| 118 | MailUtil.send(account , mailSendVO.getTos() , mailSendVO.getTitle() , mailSendVO.getContent() , false); | 112 | MailUtil.send(account , mailSendVO.getTos() , mailSendVO.getTitle() , mailSendVO.getContent() , false); |
| 119 | } | 113 | } |