code review 邮件账号的模块
parent
017d6e5e4e
commit
082c209c87
|
@ -30,7 +30,7 @@ import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
|||
@RequestMapping("/system/mail-account")
|
||||
public class MailAccountController {
|
||||
@Resource
|
||||
private MailAccountService mailAccountService;
|
||||
private MailAccountService mailAccountService; // TODO @wangjingyi:属性和类名,中间要空一行
|
||||
|
||||
@PostMapping("/create")
|
||||
@ApiOperation("创建邮箱账号")
|
||||
|
@ -50,7 +50,7 @@ public class MailAccountController {
|
|||
|
||||
@DeleteMapping("/delete")
|
||||
@ApiOperation("删除邮箱账号")
|
||||
@PreAuthorize("@ss.hasPermission('system:mail-account:delete')")
|
||||
@PreAuthorize("@ss.hasPermission('system:mail-account:delete')") // TODO @wangjingyi:id 应该是 @RequestParam。另外,id 的 swagger 注解,要写下
|
||||
public CommonResult<Boolean> deleteMailAccount(@Valid @RequestBody Long id) {
|
||||
mailAccountService.delete(id);
|
||||
return success(true);
|
||||
|
@ -63,7 +63,7 @@ public class MailAccountController {
|
|||
public CommonResult<MailAccountBaseVO> getMailAccount(@RequestParam("id") Long id) {
|
||||
MailAccountDO mailAccountDO = mailAccountService.getMailAccount(id);
|
||||
return success(MailAccountConvert.INSTANCE.convert(mailAccountDO));
|
||||
}
|
||||
} // TODO wangjingyi:方法与方法之间,只空一行
|
||||
|
||||
|
||||
@GetMapping("/page")
|
||||
|
@ -82,7 +82,7 @@ public class MailAccountController {
|
|||
list.sort(Comparator.comparing(MailAccountDO::getId));
|
||||
return success(MailAccountConvert.INSTANCE.convertList02(list));
|
||||
}
|
||||
@PostMapping("/send")
|
||||
@PostMapping("/send") // TODO wangjingyi:方法与方法之间,空一行
|
||||
@ApiOperation("发送邮件")
|
||||
@PreAuthorize("@ss.hasPermission('system:mail-account:send')")
|
||||
public CommonResult<Boolean> sendMail(MailSendVO mailSendVO){
|
||||
|
|
|
@ -2,7 +2,7 @@ package cn.iocoder.yudao.module.system.controller.admin.mail.vo.account;
|
|||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class MailAccountCreateReqVO extends MailAccountBaseVO{
|
||||
@Data // TODO @wangjingyi:swagger 注解
|
||||
public class MailAccountCreateReqVO extends MailAccountBaseVO{ // TODO @wangjingyi:要空格再 {
|
||||
|
||||
}
|
||||
|
|
|
@ -5,4 +5,6 @@ import lombok.Data;
|
|||
@Data
|
||||
public class MailAccountUpdateReqVO extends MailAccountBaseVO{
|
||||
|
||||
// TODO @wangjingyi:更新的话,是不是要有个 id???
|
||||
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@ import lombok.Data;
|
|||
|
||||
import java.util.List;
|
||||
@Data
|
||||
public class MailSendVO {
|
||||
public class MailSendVO { // TODO @wangjingyi:1)参数校验;2)ReqVO
|
||||
|
||||
@ApiModelProperty(value = "邮箱" , required = true , example = "yudaoyuanma@123.com")
|
||||
private String from;
|
||||
|
|
|
@ -13,12 +13,12 @@ import java.util.List;
|
|||
/**
|
||||
* <p>
|
||||
* 邮箱账号 Service 接口
|
||||
* </p>
|
||||
* </p> // TODO wangjingyi:不用 <p></p> 标签;
|
||||
*
|
||||
* @author wangjingyi
|
||||
* @since 2022-03-21
|
||||
*/
|
||||
public interface MailAccountService {
|
||||
public interface MailAccountService { // TODO wangjingyi:方法的注释
|
||||
|
||||
Long create(MailAccountCreateReqVO createReqVO);
|
||||
|
||||
|
|
|
@ -62,7 +62,7 @@ public class MailAccountServiceImpl implements MailAccountService {
|
|||
this.validateMailAccountOnly(map);
|
||||
MailAccountDO mailAccountDO = MailAccountConvert.INSTANCE.convert(updateReqVO);
|
||||
// 校验是否存在
|
||||
this.validateMailAccountExists(mailAccountDO.getId());
|
||||
this.validateMailAccountExists(mailAccountDO.getId()); // TODO wangjingyi:没有传递 id 噢
|
||||
mailAccountMapper.updateById(mailAccountDO);
|
||||
}
|
||||
|
||||
|
@ -92,6 +92,7 @@ public class MailAccountServiceImpl implements MailAccountService {
|
|||
@Override
|
||||
public void sendMail(MailSendVO mailSendVO) {
|
||||
// FIXME 查询模版信息 查询模版多条时 使用规则是什么
|
||||
// 回复:选择某一条模板,进行发送邮件。
|
||||
List<MailTemplateDO> mailTemplateDOList = mailTemplateMapper.selectList(
|
||||
"username",mailSendVO.getFrom()
|
||||
);
|
||||
|
@ -100,6 +101,7 @@ public class MailAccountServiceImpl implements MailAccountService {
|
|||
"from",mailSendVO.getFrom()
|
||||
);
|
||||
// FIXME 模版和邮件内容合成方式未知
|
||||
// 回复:参考短信的方式,通过 {name} {mobile} 这样的占位符。搜 formatSmsTemplateContent 方法
|
||||
String content = mailSendVO.getContent();
|
||||
String templateContent = "";
|
||||
// 后续功能 TODO :附件查询
|
||||
|
@ -119,9 +121,10 @@ public class MailAccountServiceImpl implements MailAccountService {
|
|||
}
|
||||
|
||||
private void validateMailAccountOnly(Map params){
|
||||
// TODO wangjingyi:Service 里,不允许出现 MyBatis 操作。而是 Mapper 提供对应查询方法
|
||||
QueryWrapper queryWrapper = new QueryWrapper<MailAccountDO>();
|
||||
params.forEach((k , v)->{
|
||||
queryWrapper.like(k , v);
|
||||
queryWrapper.like(k , v); // TODO wangjingyi:账号,应该是 equlas,不能是 like
|
||||
});
|
||||
if (mailAccountMapper.selectOne(queryWrapper) != null) {
|
||||
throw exception(MAIL_ACCOUNT_EXISTS);
|
||||
|
|
Loading…
Reference in New Issue