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