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