Commit 7d9a6cb2ef1c49afdff4166782be4174d8137053
1 parent
1bf1d3ee
code review 邮件模块
Showing
8 changed files
with
30 additions
and
28 deletions
yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/controller/admin/mail/MailAccountController.java
| ... | ... | @@ -48,12 +48,11 @@ public class MailAccountController { |
| 48 | 48 | return success(true); |
| 49 | 49 | } |
| 50 | 50 | |
| 51 | - | |
| 52 | 51 | @DeleteMapping("/delete") |
| 53 | 52 | @ApiOperation("删除邮箱账号") |
| 54 | 53 | @ApiImplicitParam(name = "id", value = "编号", required = true, dataTypeClass = Long.class) |
| 55 | 54 | @PreAuthorize("@ss.hasPermission('system:mail-account:delete')") |
| 56 | - public CommonResult<Boolean> deleteMailAccount(@Valid @RequestParam Long id) { | |
| 55 | + public CommonResult<Boolean> deleteMailAccount(@Valid @RequestParam Long id) { // TODO @wangjingyi:不需要 @Valid 这里。了解下 Validator | |
| 57 | 56 | mailAccountService.delete(id); |
| 58 | 57 | return success(true); |
| 59 | 58 | } |
| ... | ... | @@ -87,7 +86,7 @@ public class MailAccountController { |
| 87 | 86 | @PostMapping("/send") |
| 88 | 87 | @ApiOperation("发送邮件") |
| 89 | 88 | @PreAuthorize("@ss.hasPermission('system:mail-account:send')") |
| 90 | - public CommonResult<Boolean> sendMail(MailReqVO mailReqVO){ | |
| 89 | + public CommonResult<Boolean> sendMail(MailReqVO mailReqVO){ // TODO @wangjingyi:应该是测试短信模板,做到 MailTemplateController 里。参考下短信那的做法哈 | |
| 91 | 90 | mailAccountService.sendMail(mailReqVO); |
| 92 | 91 | return success(true); |
| 93 | 92 | } | ... | ... |
yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/controller/admin/mail/MailTemplateController.java
| ... | ... | @@ -28,7 +28,7 @@ import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |
| 28 | 28 | @RequestMapping("/system/mail-template") |
| 29 | 29 | public class MailTemplateController { |
| 30 | 30 | @Autowired |
| 31 | - MailTemplateService mailTempleService; | |
| 31 | + MailTemplateService mailTempleService; // TODO @wangjingyi:private;和上面要空一行; | |
| 32 | 32 | |
| 33 | 33 | @PostMapping("/create") |
| 34 | 34 | @ApiOperation("创建邮箱模版") |
| ... | ... | @@ -62,7 +62,6 @@ public class MailTemplateController { |
| 62 | 62 | return success(MailTemplateConvert.INSTANCE.convert(mailTemplateDO)); |
| 63 | 63 | } |
| 64 | 64 | |
| 65 | - | |
| 66 | 65 | @GetMapping("/page") |
| 67 | 66 | @ApiOperation("获得邮箱模版分页") |
| 68 | 67 | @PreAuthorize("@ss.hasPermission('system:mail-account:query')") | ... | ... |
yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/mail/MailAccountDO.java
| 1 | 1 | package cn.iocoder.yudao.module.system.dal.dataobject.mail; |
| 2 | 2 | |
| 3 | 3 | import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; |
| 4 | -import com.baomidou.mybatisplus.annotation.IdType; | |
| 5 | -import com.baomidou.mybatisplus.annotation.TableId; | |
| 6 | 4 | import com.baomidou.mybatisplus.annotation.TableField; |
| 7 | -import java.io.Serializable; | |
| 8 | - | |
| 5 | +import com.baomidou.mybatisplus.annotation.TableId; | |
| 9 | 6 | import com.baomidou.mybatisplus.annotation.TableName; |
| 10 | 7 | import io.swagger.annotations.ApiModel; |
| 11 | -import io.swagger.annotations.ApiModelProperty; | |
| 12 | 8 | import lombok.Data; |
| 13 | 9 | import lombok.EqualsAndHashCode; |
| 14 | 10 | import lombok.experimental.Accessors; |
| 15 | 11 | |
| 12 | +import java.io.Serializable; | |
| 13 | + | |
| 16 | 14 | @Data |
| 17 | 15 | @EqualsAndHashCode(callSuper = true) |
| 18 | 16 | @Accessors(chain = true) |
| 19 | -@ApiModel(value="MailAccount对象", description="邮箱账号") | |
| 20 | -@TableName(value = "system_mail_account", autoResultMap = true) | |
| 17 | +@ApiModel(value="MailAccount对象", description="邮箱账号") // TODO @wangjingyi:不需要 swagger 注解 | |
| 18 | +@TableName(value = "system_mail_account", autoResultMap = true) // TODO @wangjingyi:这个放在最上面,关键字段 | |
| 21 | 19 | public class MailAccountDO extends BaseDO implements Serializable { |
| 22 | 20 | |
| 23 | - private static final long serialVersionUID = 1L; | |
| 21 | + // TODO @wangjingyi:每个字段的注释;字段名,如果一直,不用 @TableField | |
| 22 | + | |
| 24 | 23 | @TableId |
| 25 | 24 | private Long id; |
| 26 | 25 | ... | ... |
yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/mail/MailAccountMapper.java
| ... | ... | @@ -5,14 +5,10 @@ import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; |
| 5 | 5 | import cn.iocoder.yudao.framework.mybatis.core.query.QueryWrapperX; |
| 6 | 6 | import cn.iocoder.yudao.module.system.controller.admin.mail.vo.account.MailAccountPageReqVO; |
| 7 | 7 | import cn.iocoder.yudao.module.system.dal.dataobject.mail.MailAccountDO; |
| 8 | -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | |
| 9 | 8 | import org.apache.ibatis.annotations.Mapper; |
| 10 | 9 | |
| 11 | 10 | import java.util.Map; |
| 12 | 11 | |
| 13 | -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; | |
| 14 | -import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.MAIL_ACCOUNT_EXISTS; | |
| 15 | - | |
| 16 | 12 | @Mapper |
| 17 | 13 | public interface MailAccountMapper extends BaseMapperX<MailAccountDO> { |
| 18 | 14 | |
| ... | ... | @@ -26,11 +22,12 @@ public interface MailAccountMapper extends BaseMapperX<MailAccountDO> { |
| 26 | 22 | ); |
| 27 | 23 | } |
| 28 | 24 | |
| 25 | + // TODO @wangjingyi:不要提供这样的泛的方法,而是明确的查询方法 | |
| 29 | 26 | default MailAccountDO selectByParams(Map params){ |
| 30 | 27 | QueryWrapperX queryWrapperX = new QueryWrapperX<MailAccountDO>(); |
| 31 | 28 | params.forEach((k , v)->{ |
| 32 | 29 | queryWrapperX.eqIfPresent((String) k, v); |
| 33 | 30 | }); |
| 34 | - return this.selectOne(queryWrapperX); | |
| 31 | + return this.selecOne(queryWrapperX); | |
| 35 | 32 | }; |
| 36 | 33 | } | ... | ... |
yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/service/mail/MailAccountService.java
| ... | ... | @@ -11,14 +11,17 @@ import java.util.List; |
| 11 | 11 | |
| 12 | 12 | |
| 13 | 13 | /** |
| 14 | - * 邮箱账号 Service 接口 | |
| 14 | + * 邮箱账号 Service 接口 | |
| 15 | 15 | * |
| 16 | 16 | * @author wangjingyi |
| 17 | 17 | * @since 2022-03-21 |
| 18 | 18 | */ |
| 19 | 19 | public interface MailAccountService { |
| 20 | + | |
| 21 | + // TODO @wangjingyi:注释,完整;参数校验还是要做的; | |
| 22 | + | |
| 20 | 23 | /** |
| 21 | - * 创建邮箱账号 | |
| 24 | + * 创建邮箱账号 // TODO @wangjingyi:方法描述,和参数要空行 | |
| 22 | 25 | * @param createReqVO |
| 23 | 26 | * @return |
| 24 | 27 | */ | ... | ... |
yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/service/mail/MailTemplateService.java
yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/service/mail/impl/MailAccountServiceImpl.java
| ... | ... | @@ -33,6 +33,7 @@ import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.MAIL_ACCOU |
| 33 | 33 | * @since 2022-03-21 |
| 34 | 34 | */ |
| 35 | 35 | @Service |
| 36 | +// TODO @wangjingyi:需要 @Validated 注解,开启参数校验 | |
| 36 | 37 | public class MailAccountServiceImpl implements MailAccountService { |
| 37 | 38 | |
| 38 | 39 | @Resource |
| ... | ... | @@ -54,13 +55,13 @@ public class MailAccountServiceImpl implements MailAccountService { |
| 54 | 55 | |
| 55 | 56 | @Override |
| 56 | 57 | public void update(MailAccountUpdateReqVO updateReqVO) { |
| 57 | - // username 要校验唯一 | |
| 58 | + // username 要校验唯一 TODO @wangjingyi:不要用 map 参数 | |
| 58 | 59 | Map<String , String> map = new HashMap<>(); |
| 59 | 60 | map.put("username" , updateReqVO.getUsername()); |
| 60 | - this.validateMailAccountOnly(map); | |
| 61 | + this.validateMailAccountOnly(map); // TODO @wangjingyi:如果 username 是自己用呢,要排除下自己呀 | |
| 61 | 62 | MailAccountDO mailAccountDO = MailAccountConvert.INSTANCE.convert(updateReqVO); |
| 62 | 63 | // 校验是否存在 |
| 63 | - this.validateMailAccountExists(mailAccountDO.getId()); // TODO wangjingyi:没有传递 id 噢 | |
| 64 | + this.validateMailAccountExists(mailAccountDO.getId()); | |
| 64 | 65 | mailAccountMapper.updateById(mailAccountDO); |
| 65 | 66 | } |
| 66 | 67 | ... | ... |
yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/service/mail/impl/MailTemplateServiceImpl.java
| ... | ... | @@ -6,7 +6,6 @@ import cn.iocoder.yudao.module.system.controller.admin.mail.vo.template.MailTemp |
| 6 | 6 | import cn.iocoder.yudao.module.system.controller.admin.mail.vo.template.MailTemplatePageReqVO; |
| 7 | 7 | import cn.iocoder.yudao.module.system.controller.admin.mail.vo.template.MailTemplateUpdateReqVO; |
| 8 | 8 | import cn.iocoder.yudao.module.system.convert.mail.MailTemplateConvert; |
| 9 | -import cn.iocoder.yudao.module.system.dal.dataobject.mail.MailAccountDO; | |
| 10 | 9 | import cn.iocoder.yudao.module.system.dal.dataobject.mail.MailTemplateDO; |
| 11 | 10 | import cn.iocoder.yudao.module.system.dal.mysql.mail.MailTemplateMapper; |
| 12 | 11 | import cn.iocoder.yudao.module.system.service.mail.MailTemplateService; |
| ... | ... | @@ -19,15 +18,17 @@ import java.util.List; |
| 19 | 18 | import java.util.Map; |
| 20 | 19 | |
| 21 | 20 | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; |
| 22 | -import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.*; | |
| 21 | +import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.MAIL_TEMPLATE_EXISTS; | |
| 22 | +import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.MAIL_TEMPLATE_NOT_EXISTS; | |
| 23 | 23 | |
| 24 | 24 | /** |
| 25 | - * 邮箱模版 服务实现类 | |
| 25 | + * 邮箱模版 服务实现类 | |
| 26 | 26 | * |
| 27 | 27 | * @author wangjingyi |
| 28 | 28 | * @since 2022-03-21 |
| 29 | 29 | */ |
| 30 | 30 | @Service |
| 31 | +// TODO @wangjingyi:需要 @Validated 注解,开启参数校验 | |
| 31 | 32 | public class MailTemplateServiceImpl implements MailTemplateService { |
| 32 | 33 | |
| 33 | 34 | @Resource |
| ... | ... | @@ -37,7 +38,7 @@ public class MailTemplateServiceImpl implements MailTemplateService { |
| 37 | 38 | public Long create(MailTemplateCreateReqVO createReqVO) { |
| 38 | 39 | // name 要校验唯一 |
| 39 | 40 | Map<String , String> map = new HashMap<>(); |
| 40 | - map.put("name" , createReqVO.getName()); | |
| 41 | + map.put("name" , createReqVO.getName()); // TODO @wangjingyi:模板名重复没关系的;code 不能重复 | |
| 41 | 42 | this.validateMailTemplateOnly(map); |
| 42 | 43 | MailTemplateDO mailTemplateDO = MailTemplateConvert.INSTANCE.convert(createReqVO); |
| 43 | 44 | mailTemplateMapper.insert(mailTemplateDO); |
| ... | ... | @@ -48,7 +49,7 @@ public class MailTemplateServiceImpl implements MailTemplateService { |
| 48 | 49 | public void update(MailTemplateUpdateReqVO updateReqVO) { |
| 49 | 50 | // username 要校验唯一 |
| 50 | 51 | Map<String , String> map = new HashMap<>(); |
| 51 | - map.put("username" , updateReqVO.getUsername()); | |
| 52 | + map.put("username" , updateReqVO.getUsername()); // TODO @wangjingyi:模板名重复没关系的;code 不能重复 | |
| 52 | 53 | this.validateMailTemplateOnly(map); |
| 53 | 54 | MailTemplateDO mailTemplateDO = MailTemplateConvert.INSTANCE.convert(updateReqVO); |
| 54 | 55 | // 校验是否存在 | ... | ... |