diff --git a/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/enums/ErrorCodeConstants.java b/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/enums/ErrorCodeConstants.java index 0cdab761c..7def30042 100644 --- a/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/enums/ErrorCodeConstants.java +++ b/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/enums/ErrorCodeConstants.java @@ -121,7 +121,10 @@ public interface ErrorCodeConstants { // ========== 邮箱账号 1002019000 ========== ErrorCode MAIL_ACCOUNT_NOT_EXISTS = new ErrorCode(1002019000, "邮箱账号不存在"); - ErrorCode MAIL_ACCOUNT_EXISTS = new ErrorCode(1002019000, "邮箱账号存在"); + ErrorCode MAIL_ACCOUNT_EXISTS = new ErrorCode(1002019001, "邮箱账号存在"); + // ========== 邮箱账号 1002020000 ========== + ErrorCode MAIL_TEMPLATE_NOT_EXISTS = new ErrorCode(1002020000 , "邮箱模版不存在"); + ErrorCode MAIL_TEMPLATE_EXISTS = new ErrorCode(1002020001, "邮箱账号存在"); } diff --git a/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/controller/admin/mail/MailAccountController.java b/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/controller/admin/mail/MailAccountController.java index 5cace6378..9b62bf233 100644 --- a/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/controller/admin/mail/MailAccountController.java +++ b/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/controller/admin/mail/MailAccountController.java @@ -24,14 +24,13 @@ import java.util.List; import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -@Api(tags = "管理后台 - 邮件模板") +@Api(tags = "管理后台 - 邮件账号") @RestController @RequestMapping("/system/mail-account") public class MailAccountController { @Resource private MailAccountService mailAccountService; - @PostMapping("/create") @ApiOperation("创建邮箱账号") @PreAuthorize("@ss.hasPermission('system:mail-account:create')") @@ -69,14 +68,14 @@ public class MailAccountController { @GetMapping("/page") @ApiOperation("获得邮箱账号分页") @PreAuthorize("@ss.hasPermission('system:mail-account:query')") - public CommonResult> getSmsChannelPage(@Valid MailAccountPageReqVO pageReqVO) { + public CommonResult> getMailAccountPage(@Valid MailAccountPageReqVO pageReqVO) { PageResult pageResult = mailAccountService.getMailAccountPage(pageReqVO); return success(MailAccountConvert.INSTANCE.convertPage(pageResult)); } @GetMapping("/list-all-simple") @ApiOperation(value = "获得邮箱账号精简列表") - public CommonResult> getSimpleSmsChannels() { + public CommonResult> getSimpleMailAccountList() { List list = mailAccountService.getMailAccountList(); // 排序后,返回给前端 list.sort(Comparator.comparing(MailAccountDO::getId)); diff --git a/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/controller/admin/mail/MailLogController.java b/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/controller/admin/mail/MailLogController.java index 6615448d3..f6375f290 100644 --- a/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/controller/admin/mail/MailLogController.java +++ b/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/controller/admin/mail/MailLogController.java @@ -8,14 +8,13 @@ import cn.iocoder.yudao.module.system.controller.admin.mail.vo.log.*; import cn.iocoder.yudao.module.system.convert.mail.MailLogConvert; import cn.iocoder.yudao.module.system.dal.dataobject.mail.MailLogDO; import cn.iocoder.yudao.module.system.service.mail.MailLogService; +import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; - import org.springframework.web.bind.annotation.RestController; - import javax.servlet.http.HttpServletResponse; import javax.validation.Valid; @@ -24,14 +23,8 @@ import java.util.List; import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -/** - *

- * 邮箱日志功能 - *

- * - * @author wangjingyi - * @since 2022-03-21 - */ + +@Api(tags = "管理后台 - 邮件日志") @RestController @RequestMapping("/system/mail-log") public class MailLogController { diff --git a/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/controller/admin/mail/MailTemplateController.java b/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/controller/admin/mail/MailTemplateController.java new file mode 100644 index 000000000..988882d83 --- /dev/null +++ b/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/controller/admin/mail/MailTemplateController.java @@ -0,0 +1,82 @@ +package cn.iocoder.yudao.module.system.controller.admin.mail; + +import cn.iocoder.yudao.framework.common.pojo.CommonResult; +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.module.system.controller.admin.mail.vo.template.MailTemplateBaseVO; +import cn.iocoder.yudao.module.system.controller.admin.mail.vo.template.MailTemplateCreateReqVO; +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.MailTemplateDO; +import cn.iocoder.yudao.module.system.service.mail.MailTemplateService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.*; + +import javax.validation.Valid; + +import java.util.Comparator; +import java.util.List; + +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; + +@Api(tags = "管理后台 - 邮件模版") +@RestController +@RequestMapping("/system/mail-template") +public class MailTemplateController { + @Autowired + MailTemplateService mailTempleService; + + @PostMapping("/create") + @ApiOperation("创建邮箱模版") + @PreAuthorize("@ss.hasPermission('system:mail-template:create')") + public CommonResult createMailTemplate(@Valid @RequestBody MailTemplateCreateReqVO createReqVO){ + return success(mailTempleService.create(createReqVO)); + } + + @PutMapping("/update") + @ApiOperation("修改邮箱模版") + @PreAuthorize("@ss.hasPermission('system:mail-template:update')") + public CommonResult updateMailTemplate(@Valid @RequestBody MailTemplateUpdateReqVO updateReqVO){ + mailTempleService.update(updateReqVO); + return success(true); + } + + @DeleteMapping("/delete") + @ApiOperation("删除邮箱模版") + @PreAuthorize("@ss.hasPermission('system:mail-template:delete')") + public CommonResult deleteMailTemplate(@Valid @RequestBody Long id) { + mailTempleService.delete(id); + return success(true); + } + + @GetMapping("/get") + @ApiOperation("获得邮箱模版") + @ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Long.class) + @PreAuthorize("@ss.hasPermission('system:mail-template:get')") + public CommonResult getMailTemplate(@RequestParam("id") Long id) { + MailTemplateDO mailTemplateDO = mailTempleService.getMailTemplate(id); + return success(MailTemplateConvert.INSTANCE.convert(mailTemplateDO)); + } + + + @GetMapping("/page") + @ApiOperation("获得邮箱模版分页") + @PreAuthorize("@ss.hasPermission('system:mail-account:query')") + public CommonResult> getMailTemplatePage(@Valid MailTemplatePageReqVO pageReqVO) { + PageResult pageResult = mailTempleService.getMailTemplatePage(pageReqVO); + return success(MailTemplateConvert.INSTANCE.convertPage(pageResult)); + } + + @GetMapping("/list-all-simple") + @ApiOperation(value = "获得邮箱模版精简列表") + public CommonResult> getSimpleTemplateList() { + List list = mailTempleService.getMailTemplateList(); + // 排序后,返回给前端 + list.sort(Comparator.comparing(MailTemplateDO::getId)); + return success(MailTemplateConvert.INSTANCE.convertList02(list)); + } +} diff --git a/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/controller/admin/mail/MailTempleController.java b/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/controller/admin/mail/MailTempleController.java deleted file mode 100644 index 7a4151fbe..000000000 --- a/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/controller/admin/mail/MailTempleController.java +++ /dev/null @@ -1,20 +0,0 @@ -package cn.iocoder.yudao.module.system.controller.admin.mail; - - -import org.springframework.web.bind.annotation.RequestMapping; - -import org.springframework.web.bind.annotation.RestController; - -/** - *

- * 前端控制器 - *

- * - * @author wangjingyi - * @since 2022-03-21 - */ -@RestController -@RequestMapping("/system-mail-temple") -public class MailTempleController { - -} diff --git a/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/controller/admin/mail/vo/log/MailLogBaseVO.java b/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/controller/admin/mail/vo/log/MailLogBaseVO.java index 80b6e8828..eec39193c 100644 --- a/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/controller/admin/mail/vo/log/MailLogBaseVO.java +++ b/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/controller/admin/mail/vo/log/MailLogBaseVO.java @@ -15,10 +15,10 @@ public class MailLogBaseVO { private String from; @ApiModelProperty(value = "模版编号" , required = false , example = "templeId") - private String templeId; + private String templateId; @ApiModelProperty(value = "模版code" , required = false , example = "templeCode") - private String templeCode; + private String templateCode; @ApiModelProperty(value = "标题" , required = false , example = "芋道源码") private String title; diff --git a/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/controller/admin/mail/vo/log/MailLogExcelVO.java b/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/controller/admin/mail/vo/log/MailLogExcelVO.java index e6eee9f19..03d439f33 100644 --- a/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/controller/admin/mail/vo/log/MailLogExcelVO.java +++ b/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/controller/admin/mail/vo/log/MailLogExcelVO.java @@ -1,12 +1,14 @@ package cn.iocoder.yudao.module.system.controller.admin.mail.vo.log; import com.alibaba.excel.annotation.ExcelProperty; +import lombok.Data; import org.springframework.format.annotation.DateTimeFormat; import java.sql.Timestamp; import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; +@Data public class MailLogExcelVO { @ExcelProperty(value = "邮箱" ) diff --git a/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/controller/admin/mail/vo/log/MailLogPageReqVO.java b/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/controller/admin/mail/vo/log/MailLogPageReqVO.java index a12953af4..7ed4419b7 100644 --- a/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/controller/admin/mail/vo/log/MailLogPageReqVO.java +++ b/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/controller/admin/mail/vo/log/MailLogPageReqVO.java @@ -8,16 +8,17 @@ import org.springframework.format.annotation.DateTimeFormat; import java.sql.Timestamp; import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; + @Data public class MailLogPageReqVO extends PageParam { @ApiModelProperty(value = "邮箱" , required = false , example = "yudaoyuanma@123.com") private String from; @ApiModelProperty(value = "模版编号" , required = false , example = "templeId") - private String templeId; + private String templateId; @ApiModelProperty(value = "模版code" , required = false , example = "templeCode") - private String templeCode; + private String templateCode; @ApiModelProperty(value = "标题" , required = false , example = "芋道源码") private String title; diff --git a/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/controller/admin/mail/vo/log/MailLogRespVO.java b/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/controller/admin/mail/vo/log/MailLogRespVO.java index 9bbf35179..c3c5a2fdd 100644 --- a/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/controller/admin/mail/vo/log/MailLogRespVO.java +++ b/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/controller/admin/mail/vo/log/MailLogRespVO.java @@ -1,4 +1,41 @@ package cn.iocoder.yudao.module.system.controller.admin.mail.vo.log; -public class MailLogRespVO extends MailLogBaseVO { +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import org.springframework.format.annotation.DateTimeFormat; + +import java.sql.Timestamp; + +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; +@Data +public class MailLogRespVO { + + @ApiModelProperty(value = "邮箱" , required = false , example = "yudaoyuanma@123.com") + private String from; + + @ApiModelProperty(value = "模版编号" , required = false , example = "templeId") + private String templateId; + + @ApiModelProperty(value = "模版code" , required = false , example = "templeCode") + private String templateCode; + + @ApiModelProperty(value = "标题" , required = false , example = "芋道源码") + private String title; + + @ApiModelProperty(value = "内容" , required = false , example = "遇到源码") + private String content; + + @ApiModelProperty(value = "收件人" , required = false , example = "yudaoyuanma@456.com") + private String to; + + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + @ApiModelProperty(value = "发送时间" , required = false , example = "2022-03-26 03:45:20") + private Timestamp sendTime; + + @ApiModelProperty(value = "发送状态" , required = false , example = "1") + private Boolean sendStatus; + + @ApiModelProperty(value = "发送结果" , required = false , example = "yudaoyuanma@123.com") + private String sendResult; + } diff --git a/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/controller/admin/mail/vo/template/MailTemplateBaseVO.java b/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/controller/admin/mail/vo/template/MailTemplateBaseVO.java new file mode 100644 index 000000000..b0577b44e --- /dev/null +++ b/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/controller/admin/mail/vo/template/MailTemplateBaseVO.java @@ -0,0 +1,31 @@ +package cn.iocoder.yudao.module.system.controller.admin.mail.vo.template; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +@Data +public class MailTemplateBaseVO { + @ApiModelProperty("主键") + private Long id; + + @ApiModelProperty("名称") + private String name; + + @ApiModelProperty("标识") + private String code; + + @ApiModelProperty("发件人") + private String username; + + @ApiModelProperty("标题") + private String title; + + @ApiModelProperty("内容") + private String content; + + @ApiModelProperty("状态") + private String status; + + @ApiModelProperty("备注") + private String remark; +} diff --git a/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/controller/admin/mail/vo/template/MailTemplateCreateReqVO.java b/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/controller/admin/mail/vo/template/MailTemplateCreateReqVO.java new file mode 100644 index 000000000..e18c39026 --- /dev/null +++ b/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/controller/admin/mail/vo/template/MailTemplateCreateReqVO.java @@ -0,0 +1,10 @@ +package cn.iocoder.yudao.module.system.controller.admin.mail.vo.template; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +@Data +public class MailTemplateCreateReqVO extends MailTemplateBaseVO{ + + +} diff --git a/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/controller/admin/mail/vo/template/MailTemplatePageReqVO.java b/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/controller/admin/mail/vo/template/MailTemplatePageReqVO.java new file mode 100644 index 000000000..5725febd0 --- /dev/null +++ b/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/controller/admin/mail/vo/template/MailTemplatePageReqVO.java @@ -0,0 +1,32 @@ +package cn.iocoder.yudao.module.system.controller.admin.mail.vo.template; + +import cn.iocoder.yudao.framework.common.pojo.PageParam; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +@Data +public class MailTemplatePageReqVO extends PageParam { + @ApiModelProperty("主键") + private Long id; + + @ApiModelProperty("名称") + private String name; + + @ApiModelProperty("标识") + private String code; + + @ApiModelProperty("发件人") + private String username; + + @ApiModelProperty("标题") + private String title; + + @ApiModelProperty("内容") + private String content; + + @ApiModelProperty("状态") + private String status; + + @ApiModelProperty("备注") + private String remark; +} diff --git a/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/controller/admin/mail/vo/template/MailTemplateUpdateReqVO.java b/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/controller/admin/mail/vo/template/MailTemplateUpdateReqVO.java new file mode 100644 index 000000000..ed0d882bb --- /dev/null +++ b/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/controller/admin/mail/vo/template/MailTemplateUpdateReqVO.java @@ -0,0 +1,7 @@ +package cn.iocoder.yudao.module.system.controller.admin.mail.vo.template; + +import lombok.Data; + +@Data +public class MailTemplateUpdateReqVO extends MailTemplateBaseVO{ +} diff --git a/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/convert/mail/MailTemplateConvert.java b/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/convert/mail/MailTemplateConvert.java new file mode 100644 index 000000000..3f4693bcb --- /dev/null +++ b/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/convert/mail/MailTemplateConvert.java @@ -0,0 +1,26 @@ +package cn.iocoder.yudao.module.system.convert.mail; + +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.module.system.controller.admin.mail.vo.account.MailAccountBaseVO; +import cn.iocoder.yudao.module.system.controller.admin.mail.vo.template.MailTemplateBaseVO; +import cn.iocoder.yudao.module.system.controller.admin.mail.vo.template.MailTemplateCreateReqVO; +import cn.iocoder.yudao.module.system.convert.errorcode.ErrorCodeConvertImpl; +import cn.iocoder.yudao.module.system.dal.dataobject.mail.MailAccountDO; +import cn.iocoder.yudao.module.system.dal.dataobject.mail.MailTemplateDO; +import org.mapstruct.Mapper; +import org.mapstruct.factory.Mappers; + +import java.util.List; + +@Mapper +public interface MailTemplateConvert { + MailTemplateConvert INSTANCE = Mappers.getMapper(MailTemplateConvert.class); + + MailTemplateDO convert(MailTemplateBaseVO baseVO); + + MailTemplateBaseVO convert(MailTemplateDO mailTemplateDO); + + PageResult convertPage(PageResult pageResult); + + List convertList02(List list); +} diff --git a/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/mail/MailLogDO.java b/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/mail/MailLogDO.java index ae3d603da..8183174a1 100644 --- a/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/mail/MailLogDO.java +++ b/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/mail/MailLogDO.java @@ -1,20 +1,18 @@ 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 java.sql.Timestamp; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableField; import java.io.Serializable; import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.experimental.Accessors; /** *

- * + * 邮箱日志 *

* * @author wangjingyi @@ -36,11 +34,11 @@ public class MailLogDO extends BaseDO implements Serializable { @TableField("from") private String from; - @TableField("temple_id") - private String templeId; + @TableField("template_id") + private String templateId; - @TableField("temple_code") - private String templeCode; + @TableField("template_code") + private String templateCode; @TableField("title") private String title; diff --git a/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/mail/MailTempleDO.java b/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/mail/MailTemplateDO.java similarity index 88% rename from yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/mail/MailTempleDO.java rename to yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/mail/MailTemplateDO.java index c48de644d..e2d5a6d8c 100644 --- a/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/mail/MailTempleDO.java +++ b/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/mail/MailTemplateDO.java @@ -13,7 +13,7 @@ import lombok.experimental.Accessors; /** *

- * 邮箱账号 + * 邮箱模版 *

* * @author wangjingyi @@ -22,8 +22,8 @@ import lombok.experimental.Accessors; @Data @EqualsAndHashCode(callSuper = true) @Accessors(chain = true) -@ApiModel(value="SystemMailTemple对象", description="") -public class MailTempleDO extends BaseDO implements Serializable { +@ApiModel(value="SystemMailTemplate对象", description="") +public class MailTemplateDO extends BaseDO implements Serializable { private static final long serialVersionUID = 1L; @TableId diff --git a/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/mail/MailLogMapper.java b/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/mail/MailLogMapper.java index 51be49019..a8b8ccf61 100644 --- a/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/mail/MailLogMapper.java +++ b/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/mail/MailLogMapper.java @@ -6,15 +6,16 @@ import cn.iocoder.yudao.framework.mybatis.core.query.QueryWrapperX; import cn.iocoder.yudao.module.system.controller.admin.mail.vo.log.MailLogExportReqVO; import cn.iocoder.yudao.module.system.controller.admin.mail.vo.log.MailLogPageReqVO; import cn.iocoder.yudao.module.system.dal.dataobject.mail.MailLogDO; +import org.apache.ibatis.annotations.Mapper; import java.util.List; - +@Mapper public interface MailLogMapper extends BaseMapperX { default PageResult selectPage(MailLogPageReqVO pageVO){ return selectPage(pageVO , new QueryWrapperX() .eqIfPresent("from", pageVO.getFrom()) - .eqIfPresent("templeCode", pageVO.getTempleCode()) + .eqIfPresent("templeCode", pageVO.getTemplateCode()) .likeIfPresent("title" , pageVO.getTitle()) .likeIfPresent("content" , pageVO.getContent()) .eqIfPresent("to", pageVO.getTo()) @@ -28,7 +29,7 @@ public interface MailLogMapper extends BaseMapperX { default List selectList(MailLogExportReqVO exportReqVO){ return selectList(new QueryWrapperX() .eqIfPresent("from", exportReqVO.getFrom()) - .eqIfPresent("templeCode", exportReqVO.getTempleCode()) + .eqIfPresent("templeCode", exportReqVO.getTemplateCode()) .likeIfPresent("title" , exportReqVO.getTitle()) .likeIfPresent("content" , exportReqVO.getContent()) .eqIfPresent("to", exportReqVO.getTo()) diff --git a/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/mail/MailTemplateMapper.java b/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/mail/MailTemplateMapper.java new file mode 100644 index 000000000..06e76d9ab --- /dev/null +++ b/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/mail/MailTemplateMapper.java @@ -0,0 +1,25 @@ +package cn.iocoder.yudao.module.system.dal.mysql.mail; + +import cn.iocoder.yudao.framework.common.pojo.PageResult; +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.template.MailTemplatePageReqVO; +import cn.iocoder.yudao.module.system.dal.dataobject.mail.MailTemplateDO; +import org.apache.ibatis.annotations.Mapper; + + +@Mapper +public interface MailTemplateMapper extends BaseMapperX { + + default PageResult selectPage(MailTemplatePageReqVO pageReqVO){ + return selectPage(pageReqVO , new QueryWrapperX() + .likeIfPresent("name" , pageReqVO.getName()) + .likeIfPresent("username" , pageReqVO.getUsername()) + .likeIfPresent("title" , pageReqVO.getTitle()) + .likeIfPresent("content" , pageReqVO.getContent()) + .eqIfPresent("status" , pageReqVO.getStatus()) + .likeIfPresent("remark" , pageReqVO.getRemark()) + ); + } + +} diff --git a/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/mail/MailTempleMapper.java b/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/mail/MailTempleMapper.java deleted file mode 100644 index 0264ca301..000000000 --- a/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/mail/MailTempleMapper.java +++ /dev/null @@ -1,16 +0,0 @@ -package cn.iocoder.yudao.module.system.dal.mysql.mail; - -import cn.iocoder.yudao.module.system.dal.dataobject.mail.MailTempleDO; -import com.baomidou.mybatisplus.core.mapper.BaseMapper; - -/** - *

- * Mapper 接口 - *

- * - * @author wangjingyi - * @since 2022-03-21 - */ -public interface MailTempleMapper extends BaseMapper { - -} diff --git a/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/service/mail/MailTemplateService.java b/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/service/mail/MailTemplateService.java new file mode 100644 index 000000000..3aaf72a48 --- /dev/null +++ b/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/service/mail/MailTemplateService.java @@ -0,0 +1,33 @@ +package cn.iocoder.yudao.module.system.service.mail; + +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.module.system.controller.admin.mail.vo.template.MailTemplateCreateReqVO; +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.dal.dataobject.mail.MailAccountDO; +import cn.iocoder.yudao.module.system.dal.dataobject.mail.MailTemplateDO; + +import java.util.List; + +/** + *

+ * 服务类 + *

+ * + * @author wangjingyi + * @since 2022-03-21 + */ +public interface MailTemplateService { + + Long create(MailTemplateCreateReqVO createReqVO); + + void update(MailTemplateUpdateReqVO updateReqVO); + + void delete(Long id); + + MailTemplateDO getMailTemplate(Long id); + + PageResult getMailTemplatePage(MailTemplatePageReqVO pageReqVO); + + List getMailTemplateList(); +} diff --git a/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/service/mail/MailTempleService.java b/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/service/mail/MailTempleService.java deleted file mode 100644 index 3c14626f9..000000000 --- a/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/service/mail/MailTempleService.java +++ /dev/null @@ -1,13 +0,0 @@ -package cn.iocoder.yudao.module.system.service.mail; - -/** - *

- * 服务类 - *

- * - * @author wangjingyi - * @since 2022-03-21 - */ -public interface MailTempleService { - -} diff --git a/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/service/mail/impl/MailTemplateServiceImpl.java b/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/service/mail/impl/MailTemplateServiceImpl.java new file mode 100644 index 000000000..377bbd658 --- /dev/null +++ b/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/service/mail/impl/MailTemplateServiceImpl.java @@ -0,0 +1,92 @@ +package cn.iocoder.yudao.module.system.service.mail.impl; + + +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.module.system.controller.admin.mail.vo.template.MailTemplateCreateReqVO; +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; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.util.HashMap; +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.*; + +/** + *

+ * 邮箱模版 服务实现类 + *

+ * + * @author wangjingyi + * @since 2022-03-21 + */ +@Service +public class MailTemplateServiceImpl implements MailTemplateService { + @Resource + private MailTemplateMapper mailTemplateMapper; + + @Override + public Long create(MailTemplateCreateReqVO createReqVO) { + // name 要校验唯一 + Map map = new HashMap<>(); + map.put("name" , createReqVO.getName()); + this.validateMailTemplateOnly(map); + MailTemplateDO mailTemplateDO = MailTemplateConvert.INSTANCE.convert(createReqVO); + mailTemplateMapper.insert(mailTemplateDO); + return mailTemplateDO.getId(); + } + + @Override + public void update(MailTemplateUpdateReqVO updateReqVO) { + // username 要校验唯一 + Map map = new HashMap<>(); + map.put("username" , updateReqVO.getUsername()); + this.validateMailTemplateOnly(map); + MailTemplateDO mailTemplateDO = MailTemplateConvert.INSTANCE.convert(updateReqVO); + // 校验是否存在 + this.validateMailTemplateExists(mailTemplateDO.getId()); + mailTemplateMapper.updateById(mailTemplateDO); + } + @Override + public void delete(Long id) { + // 校验是否存在 + this.validateMailTemplateExists(id); + mailTemplateMapper.deleteById(id); + } + + @Override + public MailTemplateDO getMailTemplate(Long id) {return mailTemplateMapper.selectById(id);} + + @Override + public PageResult getMailTemplatePage(MailTemplatePageReqVO pageReqVO) { + return mailTemplateMapper.selectPage(pageReqVO); + } + + @Override + public List getMailTemplateList() {return mailTemplateMapper.selectList();} + + private void validateMailTemplateExists(Long id) { + if (mailTemplateMapper.selectById(id) == null) { + throw exception(MAIL_TEMPLATE_NOT_EXISTS); + } + } + + private void validateMailTemplateOnly(Map params){ + QueryWrapper queryWrapper = new QueryWrapper(); + params.forEach((k , v)->{ + queryWrapper.like(k , v); + }); + if (mailTemplateMapper.selectOne(queryWrapper) != null) { + throw exception(MAIL_TEMPLATE_EXISTS); + } + } +} diff --git a/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/service/mail/impl/MailTempleServiceImpl.java b/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/service/mail/impl/MailTempleServiceImpl.java deleted file mode 100644 index be83bccc8..000000000 --- a/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/service/mail/impl/MailTempleServiceImpl.java +++ /dev/null @@ -1,18 +0,0 @@ -package cn.iocoder.yudao.module.system.service.mail.impl; - - -import cn.iocoder.yudao.module.system.service.mail.MailTempleService; -import org.springframework.stereotype.Service; - -/** - *

- * 服务实现类 - *

- * - * @author wangjingyi - * @since 2022-03-21 - */ -@Service -public class MailTempleServiceImpl implements MailTempleService { - -}