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