code review 邮件账号的模块

pull/2/head
YunaiV 2022-03-27 12:01:20 +08:00
parent 017d6e5e4e
commit 082c209c87
6 changed files with 16 additions and 11 deletions

View File

@ -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 @wangjingyiid 应该是 @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){

View File

@ -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 @wangjingyiswagger 注解
public class MailAccountCreateReqVO extends MailAccountBaseVO{ // TODO @wangjingyi要空格再 {
}

View File

@ -5,4 +5,6 @@ import lombok.Data;
@Data
public class MailAccountUpdateReqVO extends MailAccountBaseVO{
// TODO @wangjingyi更新的话是不是要有个 id
}

View File

@ -5,7 +5,7 @@ import lombok.Data;
import java.util.List;
@Data
public class MailSendVO {
public class MailSendVO { // TODO @wangjingyi1参数校验2ReqVO
@ApiModelProperty(value = "邮箱" , required = true , example = "yudaoyuanma@123.com")
private String from;

View File

@ -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);

View File

@ -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 wangjingyiService 里,不允许出现 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);