邮箱模版增删改查功能 修改mapstruct 相关bug

This commit is contained in:
wangjingyi 2022-03-26 06:26:36 +08:00
parent de10aa6ab2
commit 132c8b0e84
23 changed files with 405 additions and 100 deletions

View File

@ -121,7 +121,10 @@ public interface ErrorCodeConstants {
// ========== 邮箱账号 1002019000 ========== // ========== 邮箱账号 1002019000 ==========
ErrorCode MAIL_ACCOUNT_NOT_EXISTS = new ErrorCode(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, "邮箱账号存在");
} }

View File

@ -24,14 +24,13 @@ import java.util.List;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
@Api(tags = "管理后台 - 邮件模板") @Api(tags = "管理后台 - 邮件账号")
@RestController @RestController
@RequestMapping("/system/mail-account") @RequestMapping("/system/mail-account")
public class MailAccountController { public class MailAccountController {
@Resource @Resource
private MailAccountService mailAccountService; private MailAccountService mailAccountService;
@PostMapping("/create") @PostMapping("/create")
@ApiOperation("创建邮箱账号") @ApiOperation("创建邮箱账号")
@PreAuthorize("@ss.hasPermission('system:mail-account:create')") @PreAuthorize("@ss.hasPermission('system:mail-account:create')")
@ -69,14 +68,14 @@ public class MailAccountController {
@GetMapping("/page") @GetMapping("/page")
@ApiOperation("获得邮箱账号分页") @ApiOperation("获得邮箱账号分页")
@PreAuthorize("@ss.hasPermission('system:mail-account:query')") @PreAuthorize("@ss.hasPermission('system:mail-account:query')")
public CommonResult<PageResult<MailAccountBaseVO>> getSmsChannelPage(@Valid MailAccountPageReqVO pageReqVO) { public CommonResult<PageResult<MailAccountBaseVO>> getMailAccountPage(@Valid MailAccountPageReqVO pageReqVO) {
PageResult<MailAccountDO> pageResult = mailAccountService.getMailAccountPage(pageReqVO); PageResult<MailAccountDO> pageResult = mailAccountService.getMailAccountPage(pageReqVO);
return success(MailAccountConvert.INSTANCE.convertPage(pageResult)); return success(MailAccountConvert.INSTANCE.convertPage(pageResult));
} }
@GetMapping("/list-all-simple") @GetMapping("/list-all-simple")
@ApiOperation(value = "获得邮箱账号精简列表") @ApiOperation(value = "获得邮箱账号精简列表")
public CommonResult<List<MailAccountBaseVO>> getSimpleSmsChannels() { public CommonResult<List<MailAccountBaseVO>> getSimpleMailAccountList() {
List<MailAccountDO> list = mailAccountService.getMailAccountList(); List<MailAccountDO> list = mailAccountService.getMailAccountList();
// 排序后返回给前端 // 排序后返回给前端
list.sort(Comparator.comparing(MailAccountDO::getId)); list.sort(Comparator.comparing(MailAccountDO::getId));

View File

@ -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.convert.mail.MailLogConvert;
import cn.iocoder.yudao.module.system.dal.dataobject.mail.MailLogDO; import cn.iocoder.yudao.module.system.dal.dataobject.mail.MailLogDO;
import cn.iocoder.yudao.module.system.service.mail.MailLogService; import cn.iocoder.yudao.module.system.service.mail.MailLogService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid; import javax.validation.Valid;
@ -24,14 +23,8 @@ import java.util.List;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
/**
* <p> @Api(tags = "管理后台 - 邮件日志")
* 邮箱日志功能
* </p>
*
* @author wangjingyi
* @since 2022-03-21
*/
@RestController @RestController
@RequestMapping("/system/mail-log") @RequestMapping("/system/mail-log")
public class MailLogController { public class MailLogController {

View File

@ -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<Long> createMailTemplate(@Valid @RequestBody MailTemplateCreateReqVO createReqVO){
return success(mailTempleService.create(createReqVO));
}
@PutMapping("/update")
@ApiOperation("修改邮箱模版")
@PreAuthorize("@ss.hasPermission('system:mail-template:update')")
public CommonResult<Boolean> updateMailTemplate(@Valid @RequestBody MailTemplateUpdateReqVO updateReqVO){
mailTempleService.update(updateReqVO);
return success(true);
}
@DeleteMapping("/delete")
@ApiOperation("删除邮箱模版")
@PreAuthorize("@ss.hasPermission('system:mail-template:delete')")
public CommonResult<Boolean> 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<MailTemplateBaseVO> 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<PageResult<MailTemplateBaseVO>> getMailTemplatePage(@Valid MailTemplatePageReqVO pageReqVO) {
PageResult<MailTemplateDO> pageResult = mailTempleService.getMailTemplatePage(pageReqVO);
return success(MailTemplateConvert.INSTANCE.convertPage(pageResult));
}
@GetMapping("/list-all-simple")
@ApiOperation(value = "获得邮箱模版精简列表")
public CommonResult<List<MailTemplateBaseVO>> getSimpleTemplateList() {
List<MailTemplateDO> list = mailTempleService.getMailTemplateList();
// 排序后返回给前端
list.sort(Comparator.comparing(MailTemplateDO::getId));
return success(MailTemplateConvert.INSTANCE.convertList02(list));
}
}

View File

@ -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;
/**
* <p>
* 前端控制器
* </p>
*
* @author wangjingyi
* @since 2022-03-21
*/
@RestController
@RequestMapping("/system-mail-temple")
public class MailTempleController {
}

View File

@ -15,10 +15,10 @@ public class MailLogBaseVO {
private String from; private String from;
@ApiModelProperty(value = "模版编号" , required = false , example = "templeId") @ApiModelProperty(value = "模版编号" , required = false , example = "templeId")
private String templeId; private String templateId;
@ApiModelProperty(value = "模版code" , required = false , example = "templeCode") @ApiModelProperty(value = "模版code" , required = false , example = "templeCode")
private String templeCode; private String templateCode;
@ApiModelProperty(value = "标题" , required = false , example = "芋道源码") @ApiModelProperty(value = "标题" , required = false , example = "芋道源码")
private String title; private String title;

View File

@ -1,12 +1,14 @@
package cn.iocoder.yudao.module.system.controller.admin.mail.vo.log; package cn.iocoder.yudao.module.system.controller.admin.mail.vo.log;
import com.alibaba.excel.annotation.ExcelProperty; import com.alibaba.excel.annotation.ExcelProperty;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat; import org.springframework.format.annotation.DateTimeFormat;
import java.sql.Timestamp; import java.sql.Timestamp;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
@Data
public class MailLogExcelVO { public class MailLogExcelVO {
@ExcelProperty(value = "邮箱" ) @ExcelProperty(value = "邮箱" )

View File

@ -8,16 +8,17 @@ import org.springframework.format.annotation.DateTimeFormat;
import java.sql.Timestamp; import java.sql.Timestamp;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
@Data @Data
public class MailLogPageReqVO extends PageParam { public class MailLogPageReqVO extends PageParam {
@ApiModelProperty(value = "邮箱" , required = false , example = "yudaoyuanma@123.com") @ApiModelProperty(value = "邮箱" , required = false , example = "yudaoyuanma@123.com")
private String from; private String from;
@ApiModelProperty(value = "模版编号" , required = false , example = "templeId") @ApiModelProperty(value = "模版编号" , required = false , example = "templeId")
private String templeId; private String templateId;
@ApiModelProperty(value = "模版code" , required = false , example = "templeCode") @ApiModelProperty(value = "模版code" , required = false , example = "templeCode")
private String templeCode; private String templateCode;
@ApiModelProperty(value = "标题" , required = false , example = "芋道源码") @ApiModelProperty(value = "标题" , required = false , example = "芋道源码")
private String title; private String title;

View File

@ -1,4 +1,41 @@
package cn.iocoder.yudao.module.system.controller.admin.mail.vo.log; 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;
} }

View File

@ -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;
}

View File

@ -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{
}

View File

@ -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;
}

View File

@ -0,0 +1,7 @@
package cn.iocoder.yudao.module.system.controller.admin.mail.vo.template;
import lombok.Data;
@Data
public class MailTemplateUpdateReqVO extends MailTemplateBaseVO{
}

View File

@ -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<MailTemplateBaseVO> convertPage(PageResult<MailTemplateDO> pageResult);
List<MailTemplateBaseVO> convertList02(List<MailTemplateDO> list);
}

View File

@ -1,20 +1,18 @@
package cn.iocoder.yudao.module.system.dal.dataobject.mail; package cn.iocoder.yudao.module.system.dal.dataobject.mail;
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
import com.baomidou.mybatisplus.annotation.IdType;
import java.sql.Timestamp; import java.sql.Timestamp;
import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableField;
import java.io.Serializable; import java.io.Serializable;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors; import lombok.experimental.Accessors;
/** /**
* <p> * <p>
* * 邮箱日志
* </p> * </p>
* *
* @author wangjingyi * @author wangjingyi
@ -36,11 +34,11 @@ public class MailLogDO extends BaseDO implements Serializable {
@TableField("from") @TableField("from")
private String from; private String from;
@TableField("temple_id") @TableField("template_id")
private String templeId; private String templateId;
@TableField("temple_code") @TableField("template_code")
private String templeCode; private String templateCode;
@TableField("title") @TableField("title")
private String title; private String title;

View File

@ -13,7 +13,7 @@ import lombok.experimental.Accessors;
/** /**
* <p> * <p>
* 邮箱账号 * 邮箱模版
* </p> * </p>
* *
* @author wangjingyi * @author wangjingyi
@ -22,8 +22,8 @@ import lombok.experimental.Accessors;
@Data @Data
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
@Accessors(chain = true) @Accessors(chain = true)
@ApiModel(value="SystemMailTemple对象", description="") @ApiModel(value="SystemMailTemplate对象", description="")
public class MailTempleDO extends BaseDO implements Serializable { public class MailTemplateDO extends BaseDO implements Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@TableId @TableId

View File

@ -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.MailLogExportReqVO;
import cn.iocoder.yudao.module.system.controller.admin.mail.vo.log.MailLogPageReqVO; import cn.iocoder.yudao.module.system.controller.admin.mail.vo.log.MailLogPageReqVO;
import cn.iocoder.yudao.module.system.dal.dataobject.mail.MailLogDO; import cn.iocoder.yudao.module.system.dal.dataobject.mail.MailLogDO;
import org.apache.ibatis.annotations.Mapper;
import java.util.List; import java.util.List;
@Mapper
public interface MailLogMapper extends BaseMapperX<MailLogDO> { public interface MailLogMapper extends BaseMapperX<MailLogDO> {
default PageResult<MailLogDO> selectPage(MailLogPageReqVO pageVO){ default PageResult<MailLogDO> selectPage(MailLogPageReqVO pageVO){
return selectPage(pageVO , new QueryWrapperX<MailLogDO>() return selectPage(pageVO , new QueryWrapperX<MailLogDO>()
.eqIfPresent("from", pageVO.getFrom()) .eqIfPresent("from", pageVO.getFrom())
.eqIfPresent("templeCode", pageVO.getTempleCode()) .eqIfPresent("templeCode", pageVO.getTemplateCode())
.likeIfPresent("title" , pageVO.getTitle()) .likeIfPresent("title" , pageVO.getTitle())
.likeIfPresent("content" , pageVO.getContent()) .likeIfPresent("content" , pageVO.getContent())
.eqIfPresent("to", pageVO.getTo()) .eqIfPresent("to", pageVO.getTo())
@ -28,7 +29,7 @@ public interface MailLogMapper extends BaseMapperX<MailLogDO> {
default List<MailLogDO> selectList(MailLogExportReqVO exportReqVO){ default List<MailLogDO> selectList(MailLogExportReqVO exportReqVO){
return selectList(new QueryWrapperX<MailLogDO>() return selectList(new QueryWrapperX<MailLogDO>()
.eqIfPresent("from", exportReqVO.getFrom()) .eqIfPresent("from", exportReqVO.getFrom())
.eqIfPresent("templeCode", exportReqVO.getTempleCode()) .eqIfPresent("templeCode", exportReqVO.getTemplateCode())
.likeIfPresent("title" , exportReqVO.getTitle()) .likeIfPresent("title" , exportReqVO.getTitle())
.likeIfPresent("content" , exportReqVO.getContent()) .likeIfPresent("content" , exportReqVO.getContent())
.eqIfPresent("to", exportReqVO.getTo()) .eqIfPresent("to", exportReqVO.getTo())

View File

@ -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<MailTemplateDO> {
default PageResult<MailTemplateDO> selectPage(MailTemplatePageReqVO pageReqVO){
return selectPage(pageReqVO , new QueryWrapperX<MailTemplateDO>()
.likeIfPresent("name" , pageReqVO.getName())
.likeIfPresent("username" , pageReqVO.getUsername())
.likeIfPresent("title" , pageReqVO.getTitle())
.likeIfPresent("content" , pageReqVO.getContent())
.eqIfPresent("status" , pageReqVO.getStatus())
.likeIfPresent("remark" , pageReqVO.getRemark())
);
}
}

View File

@ -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;
/**
* <p>
* Mapper 接口
* </p>
*
* @author wangjingyi
* @since 2022-03-21
*/
public interface MailTempleMapper extends BaseMapper<MailTempleDO> {
}

View File

@ -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;
/**
* <p>
* 服务类
* </p>
*
* @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<MailTemplateDO> getMailTemplatePage(MailTemplatePageReqVO pageReqVO);
List<MailTemplateDO> getMailTemplateList();
}

View File

@ -1,13 +0,0 @@
package cn.iocoder.yudao.module.system.service.mail;
/**
* <p>
* 服务类
* </p>
*
* @author wangjingyi
* @since 2022-03-21
*/
public interface MailTempleService {
}

View File

@ -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.*;
/**
* <p>
* 邮箱模版 服务实现类
* </p>
*
* @author wangjingyi
* @since 2022-03-21
*/
@Service
public class MailTemplateServiceImpl implements MailTemplateService {
@Resource
private MailTemplateMapper mailTemplateMapper;
@Override
public Long create(MailTemplateCreateReqVO createReqVO) {
// name 要校验唯一
Map<String , String> 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<String , String> 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<MailTemplateDO> getMailTemplatePage(MailTemplatePageReqVO pageReqVO) {
return mailTemplateMapper.selectPage(pageReqVO);
}
@Override
public List<MailTemplateDO> 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<MailTemplateDO>();
params.forEach((k , v)->{
queryWrapper.like(k , v);
});
if (mailTemplateMapper.selectOne(queryWrapper) != null) {
throw exception(MAIL_TEMPLATE_EXISTS);
}
}
}

View File

@ -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;
/**
* <p>
* 服务实现类
* </p>
*
* @author wangjingyi
* @since 2022-03-21
*/
@Service
public class MailTempleServiceImpl implements MailTempleService {
}