Commit 082c209c87feb9e193fa3811e7d1757b1428717b
1 parent
017d6e5e
code review 邮件账号的模块
Showing
6 changed files
with
16 additions
and
11 deletions
yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/controller/admin/mail/MailAccountController.java
| ... | ... | @@ -30,7 +30,7 @@ import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |
| 30 | 30 | @RequestMapping("/system/mail-account") |
| 31 | 31 | public class MailAccountController { |
| 32 | 32 | @Resource |
| 33 | - private MailAccountService mailAccountService; | |
| 33 | + private MailAccountService mailAccountService; // TODO @wangjingyi:属性和类名,中间要空一行 | |
| 34 | 34 | |
| 35 | 35 | @PostMapping("/create") |
| 36 | 36 | @ApiOperation("创建邮箱账号") |
| ... | ... | @@ -50,7 +50,7 @@ public class MailAccountController { |
| 50 | 50 | |
| 51 | 51 | @DeleteMapping("/delete") |
| 52 | 52 | @ApiOperation("删除邮箱账号") |
| 53 | - @PreAuthorize("@ss.hasPermission('system:mail-account:delete')") | |
| 53 | + @PreAuthorize("@ss.hasPermission('system:mail-account:delete')") // TODO @wangjingyi:id 应该是 @RequestParam。另外,id 的 swagger 注解,要写下 | |
| 54 | 54 | public CommonResult<Boolean> deleteMailAccount(@Valid @RequestBody Long id) { |
| 55 | 55 | mailAccountService.delete(id); |
| 56 | 56 | return success(true); |
| ... | ... | @@ -63,7 +63,7 @@ public class MailAccountController { |
| 63 | 63 | public CommonResult<MailAccountBaseVO> getMailAccount(@RequestParam("id") Long id) { |
| 64 | 64 | MailAccountDO mailAccountDO = mailAccountService.getMailAccount(id); |
| 65 | 65 | return success(MailAccountConvert.INSTANCE.convert(mailAccountDO)); |
| 66 | - } | |
| 66 | + } // TODO wangjingyi:方法与方法之间,只空一行 | |
| 67 | 67 | |
| 68 | 68 | |
| 69 | 69 | @GetMapping("/page") |
| ... | ... | @@ -82,7 +82,7 @@ public class MailAccountController { |
| 82 | 82 | list.sort(Comparator.comparing(MailAccountDO::getId)); |
| 83 | 83 | return success(MailAccountConvert.INSTANCE.convertList02(list)); |
| 84 | 84 | } |
| 85 | - @PostMapping("/send") | |
| 85 | + @PostMapping("/send") // TODO wangjingyi:方法与方法之间,空一行 | |
| 86 | 86 | @ApiOperation("发送邮件") |
| 87 | 87 | @PreAuthorize("@ss.hasPermission('system:mail-account:send')") |
| 88 | 88 | public CommonResult<Boolean> sendMail(MailSendVO mailSendVO){ | ... | ... |
yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/controller/admin/mail/vo/account/MailAccountCreateReqVO.java
| ... | ... | @@ -2,7 +2,7 @@ package cn.iocoder.yudao.module.system.controller.admin.mail.vo.account; |
| 2 | 2 | |
| 3 | 3 | import lombok.Data; |
| 4 | 4 | |
| 5 | -@Data | |
| 6 | -public class MailAccountCreateReqVO extends MailAccountBaseVO{ | |
| 5 | +@Data // TODO @wangjingyi:swagger 注解 | |
| 6 | +public class MailAccountCreateReqVO extends MailAccountBaseVO{ // TODO @wangjingyi:要空格再 { | |
| 7 | 7 | |
| 8 | 8 | } | ... | ... |
yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/controller/admin/mail/vo/account/MailAccountUpdateReqVO.java
yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/controller/admin/mail/vo/send/MailSendVO.java
| ... | ... | @@ -5,7 +5,7 @@ import lombok.Data; |
| 5 | 5 | |
| 6 | 6 | import java.util.List; |
| 7 | 7 | @Data |
| 8 | -public class MailSendVO { | |
| 8 | +public class MailSendVO { // TODO @wangjingyi:1)参数校验;2)ReqVO | |
| 9 | 9 | |
| 10 | 10 | @ApiModelProperty(value = "邮箱" , required = true , example = "yudaoyuanma@123.com") |
| 11 | 11 | private String from; | ... | ... |
yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/service/mail/MailAccountService.java
| ... | ... | @@ -13,12 +13,12 @@ import java.util.List; |
| 13 | 13 | /** |
| 14 | 14 | * <p> |
| 15 | 15 | * 邮箱账号 Service 接口 |
| 16 | - * </p> | |
| 16 | + * </p> // TODO wangjingyi:不用 <p></p> 标签; | |
| 17 | 17 | * |
| 18 | 18 | * @author wangjingyi |
| 19 | 19 | * @since 2022-03-21 |
| 20 | 20 | */ |
| 21 | -public interface MailAccountService { | |
| 21 | +public interface MailAccountService { // TODO wangjingyi:方法的注释 | |
| 22 | 22 | |
| 23 | 23 | Long create(MailAccountCreateReqVO createReqVO); |
| 24 | 24 | ... | ... |
yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/service/mail/impl/MailAccountServiceImpl.java
| ... | ... | @@ -62,7 +62,7 @@ public class MailAccountServiceImpl implements MailAccountService { |
| 62 | 62 | this.validateMailAccountOnly(map); |
| 63 | 63 | MailAccountDO mailAccountDO = MailAccountConvert.INSTANCE.convert(updateReqVO); |
| 64 | 64 | // 校验是否存在 |
| 65 | - this.validateMailAccountExists(mailAccountDO.getId()); | |
| 65 | + this.validateMailAccountExists(mailAccountDO.getId()); // TODO wangjingyi:没有传递 id 噢 | |
| 66 | 66 | mailAccountMapper.updateById(mailAccountDO); |
| 67 | 67 | } |
| 68 | 68 | |
| ... | ... | @@ -92,6 +92,7 @@ public class MailAccountServiceImpl implements MailAccountService { |
| 92 | 92 | @Override |
| 93 | 93 | public void sendMail(MailSendVO mailSendVO) { |
| 94 | 94 | // FIXME 查询模版信息 查询模版多条时 使用规则是什么 |
| 95 | + // 回复:选择某一条模板,进行发送邮件。 | |
| 95 | 96 | List<MailTemplateDO> mailTemplateDOList = mailTemplateMapper.selectList( |
| 96 | 97 | "username",mailSendVO.getFrom() |
| 97 | 98 | ); |
| ... | ... | @@ -100,6 +101,7 @@ public class MailAccountServiceImpl implements MailAccountService { |
| 100 | 101 | "from",mailSendVO.getFrom() |
| 101 | 102 | ); |
| 102 | 103 | // FIXME 模版和邮件内容合成方式未知 |
| 104 | + // 回复:参考短信的方式,通过 {name} {mobile} 这样的占位符。搜 formatSmsTemplateContent 方法 | |
| 103 | 105 | String content = mailSendVO.getContent(); |
| 104 | 106 | String templateContent = ""; |
| 105 | 107 | // 后续功能 TODO :附件查询 |
| ... | ... | @@ -119,9 +121,10 @@ public class MailAccountServiceImpl implements MailAccountService { |
| 119 | 121 | } |
| 120 | 122 | |
| 121 | 123 | private void validateMailAccountOnly(Map params){ |
| 124 | + // TODO wangjingyi:Service 里,不允许出现 MyBatis 操作。而是 Mapper 提供对应查询方法 | |
| 122 | 125 | QueryWrapper queryWrapper = new QueryWrapper<MailAccountDO>(); |
| 123 | 126 | params.forEach((k , v)->{ |
| 124 | - queryWrapper.like(k , v); | |
| 127 | + queryWrapper.like(k , v); // TODO wangjingyi:账号,应该是 equlas,不能是 like | |
| 125 | 128 | }); |
| 126 | 129 | if (mailAccountMapper.selectOne(queryWrapper) != null) { |
| 127 | 130 | throw exception(MAIL_ACCOUNT_EXISTS); | ... | ... |