邮箱账号管理 TODO意见修改

This commit is contained in:
wangjingyi 2022-03-25 02:59:51 +08:00
parent 50f7af00e9
commit 54ad304514
26 changed files with 608 additions and 561 deletions

View File

@ -119,4 +119,9 @@ public interface ErrorCodeConstants {
ErrorCode SOCIAL_USER_UNBIND_NOT_SELF = new ErrorCode(1002018001, "社交解绑失败,非当前用户绑定");
ErrorCode SOCIAL_USER_NOT_FOUND = new ErrorCode(1002018002, "社交授权失败,找不到对应的用户");
// ========== 邮箱账号 1002019000 ==========
ErrorCode MAIL_ACCOUNT_NOT_EXISTS = new ErrorCode(1002019000, "邮箱账号不存在");
ErrorCode MAIL_ACCOUNT_EXISTS = new ErrorCode(1002019000, "邮箱账号存在");
}

View File

@ -0,0 +1,85 @@
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.account.MailAccountBaseVO;
import cn.iocoder.yudao.module.system.controller.admin.mail.vo.account.MailAccountCreateReqVO;
import cn.iocoder.yudao.module.system.controller.admin.mail.vo.account.MailAccountPageReqVO;
import cn.iocoder.yudao.module.system.controller.admin.mail.vo.account.MailAccountUpdateReqVO;
import cn.iocoder.yudao.module.system.convert.mail.MailAccountConvert;
import cn.iocoder.yudao.module.system.dal.dataobject.mail.MailAccountDO;
import cn.iocoder.yudao.module.system.service.mail.MailAccountService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
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-account")
public class MailAccountController {
@Resource
private MailAccountService mailAccountService;
@PostMapping("/create")
@ApiOperation("创建邮箱账号")
@PreAuthorize("@ss.hasPermission('system:mail-account:create')")
public CommonResult<Long> createMailAccount(@Valid @RequestBody MailAccountCreateReqVO createReqVO) {
return success(mailAccountService.create(createReqVO));
}
@PutMapping("/update")
@ApiOperation("修改邮箱账号")
@PreAuthorize("@ss.hasPermission('system:mail-account:update')")
public CommonResult<Boolean> updateMailAccount(@Valid @RequestBody MailAccountUpdateReqVO updateReqVO) {
mailAccountService.update(updateReqVO);
return success(true);
}
@DeleteMapping("/delete")
@ApiOperation("删除邮箱账号")
@PreAuthorize("@ss.hasPermission('system:mail-account:delete')")
public CommonResult<Boolean> deleteMailAccount(@Valid @RequestBody Long id) {
mailAccountService.delete(id);
return success(true);
}
@GetMapping("/get")
@ApiOperation("获得邮箱账号")
@ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Long.class)
@PreAuthorize("@ss.hasPermission('system:mail-account:get')")
public CommonResult<MailAccountBaseVO> getMailAccount(@RequestParam("id") Long id) {
MailAccountDO mailAccountDO = mailAccountService.getMailAccount(id);
return success(MailAccountConvert.INSTANCE.convert(mailAccountDO));
}
@GetMapping("/page")
@ApiOperation("获得邮箱账号分页")
@PreAuthorize("@ss.hasPermission('system:mail-account:query')")
public CommonResult<PageResult<MailAccountBaseVO>> getSmsChannelPage(@Valid MailAccountPageReqVO pageReqVO) {
PageResult<MailAccountDO> pageResult = mailAccountService.getMailAccountPage(pageReqVO);
return success(MailAccountConvert.INSTANCE.convertPage(pageResult));
}
@GetMapping("/list-all-simple")
@ApiOperation(value = "获得邮箱账号精简列表")
public CommonResult<List<MailAccountBaseVO>> getSimpleSmsChannels() {
List<MailAccountDO> list = mailAccountService.getMailAccountList();
// 排序后返回给前端
list.sort(Comparator.comparing(MailAccountDO::getId));
return success(MailAccountConvert.INSTANCE.convertList02(list));
}
}

View File

@ -1,20 +1,20 @@
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-log")
public class SystemMailLogController {
}
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-log")
public class MailLogController {
}

View File

@ -1,20 +1,20 @@
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 SystemMailTempleController {
}
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

@ -1,94 +0,0 @@
package cn.iocoder.yudao.module.system.controller.admin.mail;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.system.controller.admin.mail.vo.account.SystemMailAccountBaseVO;
import cn.iocoder.yudao.module.system.convert.mail.SystemMailAccountConvert;
import cn.iocoder.yudao.module.system.dal.dataobject.mail.SystemMailAccountDO;
import cn.iocoder.yudao.module.system.service.mail.SystemMailAccountService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.Comparator;
import java.util.List;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
// TODO @ジョイイ使用 Swagger 注解不用写这个注释啦
/**
* <p>
* 前端控制器
* </p>
*
* @author wangjingyi
* @since 2022-03-21
*/
@Api(tags = "管理后台 - 邮件模板")
@RestController
@RequestMapping("/system-mail-account") // TODO @ジョイイ/system/mail-account
public class SystemMailAccountController {
@Resource
private SystemMailAccountService systemMailAccountService;
// TODO @ジョイイ最好VO 分拆下参考下别的模块
@PostMapping("/create")
@ApiOperation("创建邮箱账号")
@PreAuthorize("@ss.hasPermission('system:system-mail-account:create')")
public CommonResult<Long> createMailAccount(@Valid @RequestBody SystemMailAccountBaseVO baseVO) {
return success(systemMailAccountService.create(baseVO));
}
@PutMapping("/update")
@ApiOperation("修改邮箱账号")
@PreAuthorize("@ss.hasPermission('system:system-mail-account:update')")
public CommonResult<Boolean> updateMailAccount(@Valid @RequestBody SystemMailAccountBaseVO baseVO) {
systemMailAccountService.update(baseVO);
return success(true);
}
// TODO @ジョイイ删除编号即可
@DeleteMapping("/delete")
@ApiOperation("删除邮箱账号")
@PreAuthorize("@ss.hasPermission('system:system-mail-account:delete')")
public CommonResult<Boolean> deleteMailAccount(@Valid @RequestBody SystemMailAccountBaseVO baseVO) {
systemMailAccountService.delete(baseVO);
return success(true);
}
@GetMapping("/get")
@ApiOperation("获得邮箱账号")
@ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Long.class)
@PreAuthorize("@ss.hasPermission('system:system-mail-account:get')")
public CommonResult<SystemMailAccountBaseVO> getMailAccount(@RequestParam("id") Long id) {
SystemMailAccountDO systemMailAccountDO = systemMailAccountService.getMailAccount(id);
return success(SystemMailAccountConvert.INSTANCE.convert(systemMailAccountDO));
}
// TODO @ジョイイ分页的查询条件
@GetMapping("/page")
@ApiOperation("获得邮箱账号分页")
@PreAuthorize("@ss.hasPermission('system:system-mail-account:query')")
public CommonResult<PageResult<SystemMailAccountBaseVO>> getSmsChannelPage(@Valid PageParam pageParam) {
PageResult<SystemMailAccountDO> pageResult = systemMailAccountService.getMailAccountPage(pageParam);
return success(SystemMailAccountConvert.INSTANCE.convertPage(pageResult));
}
@GetMapping("/list-all-simple")
@ApiOperation(value = "获得邮箱账号精简列表")
public CommonResult<List<SystemMailAccountBaseVO>> getSimpleSmsChannels() {
List<SystemMailAccountDO> list = systemMailAccountService.getMailAccountList();
// 排序后返回给前端
list.sort(Comparator.comparing(SystemMailAccountDO::getId));
return success(SystemMailAccountConvert.INSTANCE.convertList02(list));
}
}

View File

@ -3,12 +3,10 @@ package cn.iocoder.yudao.module.system.controller.admin.mail.vo.account;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
// TODO @ジョイイSystem 去掉哈
@Data
public class SystemMailAccountBaseVO {
public class MailAccountBaseVO {
// TODO @ジョイイexample 写的不太对这个应该是邮箱
@ApiModelProperty(value = "来源" , required = true , example = "yudaoyuanma")
@ApiModelProperty(value = "邮箱" , required = true , example = "yudaoyuanma@123.com")
private String from;
@ApiModelProperty(value = "用户名" , required = true , example = "yudao")
@ -23,7 +21,6 @@ public class SystemMailAccountBaseVO {
@ApiModelProperty(value = "端口" , required = true , example = "80")
private String port;
// TODO @ジョイイBoolean
@ApiModelProperty(value = "是否开启ssl" , required = true , example = "2")
private Integer sslEnable;
private Boolean sslEnable;
}

View File

@ -0,0 +1,8 @@
package cn.iocoder.yudao.module.system.controller.admin.mail.vo.account;
import lombok.Data;
@Data
public class MailAccountCreateReqVO extends MailAccountBaseVO{
}

View File

@ -0,0 +1,26 @@
package cn.iocoder.yudao.module.system.controller.admin.mail.vo.account;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
public class MailAccountPageReqVO extends PageParam {
@ApiModelProperty(value = "邮箱" , required = true , example = "yudaoyuanma@123.com")
private String from;
@ApiModelProperty(value = "用户名" , required = true , example = "yudao")
private String username;
@ApiModelProperty(value = "密码" , required = true , example = "123456")
private String password;
@ApiModelProperty(value = "网站" , required = true , example = "www.iocoder.cn")
private String host;
@ApiModelProperty(value = "端口" , required = true , example = "80")
private String port;
@ApiModelProperty(value = "是否开启ssl" , required = true , example = "2")
private Boolean sslEnable;
}

View File

@ -0,0 +1,8 @@
package cn.iocoder.yudao.module.system.controller.admin.mail.vo.account;
import lombok.Data;
@Data
public class MailAccountUpdateReqVO extends MailAccountBaseVO{
}

View File

@ -0,0 +1,22 @@
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.dal.dataobject.mail.MailAccountDO;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
import java.util.List;
@Mapper
public interface MailAccountConvert {
MailAccountConvert INSTANCE = Mappers.getMapper(MailAccountConvert.class);
MailAccountDO convert (MailAccountBaseVO mailAccountBaseVO);
MailAccountBaseVO convert (MailAccountDO mailAccountDO);
PageResult<MailAccountBaseVO> convertPage(PageResult<MailAccountDO> pageResult);
List<MailAccountBaseVO> convertList02(List<MailAccountDO> list);
}

View File

@ -1,25 +0,0 @@
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.SystemMailAccountBaseVO;
import cn.iocoder.yudao.module.system.controller.admin.sms.vo.channel.SmsChannelRespVO;
import cn.iocoder.yudao.module.system.controller.admin.sms.vo.channel.SmsChannelSimpleRespVO;
import cn.iocoder.yudao.module.system.dal.dataobject.mail.SystemMailAccountDO;
import cn.iocoder.yudao.module.system.dal.dataobject.sms.SmsChannelDO;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
import java.util.List;
@Mapper
public interface SystemMailAccountConvert {
SystemMailAccountConvert INSTANCE = Mappers.getMapper(SystemMailAccountConvert.class);
SystemMailAccountDO convert (SystemMailAccountBaseVO systemMailAccountBaseVO);
SystemMailAccountBaseVO convert (SystemMailAccountDO systemMailAccountDO);
PageResult<SystemMailAccountBaseVO> convertPage(PageResult<SystemMailAccountDO> pageResult);
List<SystemMailAccountBaseVO> convertList02(List<SystemMailAccountDO> list);
}

View File

@ -1,54 +1,46 @@
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.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
/**
* <p>
*
* </p>
*
* @author wangjingyi
* @since 2022-03-21
*/
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@ApiModel(value="SystemMailAccount对象", description="")
@TableName(value = "system_mail_account", autoResultMap = true)
public class SystemMailAccountDO extends BaseDO implements Serializable {
private static final long serialVersionUID = 1L;
@TableId
private Long id;
@TableField("from")
private String from;
@TableField("username")
private String username;
@TableField("password")
private String password;
@TableField("host")
private String host;
@TableField("port")
private String port;
@TableField("sslEnable")
private Integer sslEnable;
}
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.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@ApiModel(value="MailAccount对象", description="")
@TableName(value = "system_mail_account", autoResultMap = true)
public class MailAccountDO extends BaseDO implements Serializable {
private static final long serialVersionUID = 1L;
@TableId
private Long id;
@TableField("from")
private String from;
@TableField("username")
private String username;
@TableField("password")
private String password;
@TableField("host")
private String host;
@TableField("port")
private String port;
@TableField("sslEnable")
private Boolean sslEnable;
}

View File

@ -1,61 +1,61 @@
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;
/**
* <p>
*
* </p>
*
* @author wangjingyi
* @since 2022-03-21
*/
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@ApiModel(value="SystemMailLog对象", description="")
public class SystemMailLogDO extends BaseDO implements Serializable {
private static final long serialVersionUID = 1L;
@TableId
private Long id;
@TableField("account_code")
private String accountCode;
@TableField("from")
private String from;
@TableField("temple_code")
private String templeCode;
@TableField("title")
private String title;
@TableField("content")
private String content;
@TableField("to")
private String to;
@TableField("sendTime")
private Timestamp sendTime;
@TableField("sendStatus")
private String sendStatus;
@TableField("sendResult")
private String sendResult;
}
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;
/**
* <p>
*
* </p>
*
* @author wangjingyi
* @since 2022-03-21
*/
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@ApiModel(value="SystemMailLog对象", description="")
public class MailLogDO extends BaseDO implements Serializable {
private static final long serialVersionUID = 1L;
@TableId
private Long id;
@TableField("account_code")
private String accountCode;
@TableField("from")
private String from;
@TableField("temple_code")
private String templeCode;
@TableField("title")
private String title;
@TableField("content")
private String content;
@TableField("to")
private String to;
@TableField("sendTime")
private Timestamp sendTime;
@TableField("sendStatus")
private String sendStatus;
@TableField("sendResult")
private String sendResult;
}

View File

@ -1,54 +1,54 @@
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 io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
/**
* <p>
*
* </p>
*
* @author wangjingyi
* @since 2022-03-21
*/
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@ApiModel(value="SystemMailTemple对象", description="")
public class SystemMailTempleDO extends BaseDO implements Serializable {
private static final long serialVersionUID = 1L;
@TableId
private Long id;
@TableField("name")
private String name;
@TableField("code")
private String code;
@TableField("username")
private String username;
@TableField("title")
private String title;
@TableField("content")
private String content;
@TableField("status")
private String status;
@TableField("remark")
private String remark;
}
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 io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
/**
* <p>
* 邮箱账号
* </p>
*
* @author wangjingyi
* @since 2022-03-21
*/
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@ApiModel(value="SystemMailTemple对象", description="")
public class MailTempleDO extends BaseDO implements Serializable {
private static final long serialVersionUID = 1L;
@TableId
private Long id;
@TableField("name")
private String name;
@TableField("code")
private String code;
@TableField("username")
private String username;
@TableField("title")
private String title;
@TableField("content")
private String content;
@TableField("status")
private String status;
@TableField("remark")
private String remark;
}

View File

@ -0,0 +1,23 @@
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.account.MailAccountPageReqVO;
import cn.iocoder.yudao.module.system.dal.dataobject.mail.MailAccountDO;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface MailAccountMapper extends BaseMapperX<MailAccountDO> {
default PageResult<MailAccountDO> selectPage(MailAccountPageReqVO pageReqVO) {
return selectPage(pageReqVO, new QueryWrapperX<MailAccountDO>()
.likeIfPresent("form" , pageReqVO.getFrom())
.likeIfPresent("host" , pageReqVO.getHost())
.likeIfPresent("username" , pageReqVO.getUsername())
.eqIfPresent("password" , pageReqVO.getPassword())
.eqIfPresent("port" , pageReqVO.getPort())
);
}
}

View File

@ -1,16 +1,16 @@
package cn.iocoder.yudao.module.system.dal.mysql.mail;
import cn.iocoder.yudao.module.system.dal.dataobject.mail.SystemMailLogDO;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* <p>
* Mapper 接口
* </p>
*
* @author wangjingyi
* @since 2022-03-21
*/
public interface SystemMailLogMapper extends BaseMapper<SystemMailLogDO> {
}
package cn.iocoder.yudao.module.system.dal.mysql.mail;
import cn.iocoder.yudao.module.system.dal.dataobject.mail.MailLogDO;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* <p>
* Mapper 接口
* </p>
*
* @author wangjingyi
* @since 2022-03-21
*/
public interface MailLogMapper extends BaseMapper<MailLogDO> {
}

View File

@ -1,16 +1,16 @@
package cn.iocoder.yudao.module.system.dal.mysql.mail;
import cn.iocoder.yudao.module.system.dal.dataobject.mail.SystemMailTempleDO;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* <p>
* Mapper 接口
* </p>
*
* @author wangjingyi
* @since 2022-03-21
*/
public interface SystemMailTempleMapper extends BaseMapper<SystemMailTempleDO> {
}
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

@ -1,26 +0,0 @@
package cn.iocoder.yudao.module.system.dal.mysql.mail;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
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.dal.dataobject.mail.SystemMailAccountDO;
import org.apache.ibatis.annotations.Mapper;
// TODO @ジョイイ Mapper 一般不用注释因为用途不大
/**
* <p>
* Mapper 接口
* </p>
*
* @author wangjingyi
* @since 2022-03-21
*/
@Mapper
public interface SystemMailAccountMapper extends BaseMapperX<SystemMailAccountDO> {
default PageResult<SystemMailAccountDO> selectPage(PageParam pageParam) {
return selectPage(pageParam, new QueryWrapperX<SystemMailAccountDO>());
}
}

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.account.MailAccountCreateReqVO;
import cn.iocoder.yudao.module.system.controller.admin.mail.vo.account.MailAccountPageReqVO;
import cn.iocoder.yudao.module.system.controller.admin.mail.vo.account.MailAccountUpdateReqVO;
import cn.iocoder.yudao.module.system.dal.dataobject.mail.MailAccountDO;
import java.util.List;
/**
* <p>
* 邮箱账号 Service 接口
* </p>
*
* @author wangjingyi
* @since 2022-03-21
*/
public interface MailAccountService {
Long create(MailAccountCreateReqVO createReqVO);
void update(MailAccountUpdateReqVO updateReqVO);
void delete(Long id);
MailAccountDO getMailAccount(Long id);
PageResult<MailAccountDO> getMailAccountPage(MailAccountPageReqVO pageReqVO);
List<MailAccountDO> getMailAccountList();
}

View File

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

View File

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

View File

@ -1,33 +0,0 @@
package cn.iocoder.yudao.module.system.service.mail;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.system.controller.admin.mail.vo.account.SystemMailAccountBaseVO;
import cn.iocoder.yudao.module.system.dal.dataobject.mail.SystemMailAccountDO;
import java.util.List;
// TODO @ジョイイ类注释应该是 邮箱账号 Service 接口
/**
* <p>
* 服务类
* </p>
*
* @author wangjingyi
* @since 2022-03-21
*/
public interface SystemMailAccountService {
Long create(SystemMailAccountBaseVO baseVO);
String update(SystemMailAccountBaseVO baseVO);
String delete(SystemMailAccountBaseVO baseVO);
SystemMailAccountDO getMailAccount(Long id);
PageResult<SystemMailAccountDO> getMailAccountPage(PageParam pageParam);
List<SystemMailAccountDO> getMailAccountList();
}

View File

@ -0,0 +1,99 @@
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.account.MailAccountCreateReqVO;
import cn.iocoder.yudao.module.system.controller.admin.mail.vo.account.MailAccountPageReqVO;
import cn.iocoder.yudao.module.system.controller.admin.mail.vo.account.MailAccountUpdateReqVO;
import cn.iocoder.yudao.module.system.convert.mail.MailAccountConvert;
import cn.iocoder.yudao.module.system.dal.dataobject.mail.MailAccountDO;
import cn.iocoder.yudao.module.system.dal.mysql.mail.MailAccountMapper;
import cn.iocoder.yudao.module.system.service.mail.MailAccountService;
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.MAIL_ACCOUNT_EXISTS;
import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.MAIL_ACCOUNT_NOT_EXISTS;
/**
* <p>
* 邮箱账号 Service 实现类
* </p>
*
* @author wangjingyi
* @since 2022-03-21
*/
@Service
public class MailAccountServiceImpl implements MailAccountService {
@Resource
private MailAccountMapper mailAccountMapper;
@Override
public Long create(MailAccountCreateReqVO createReqVO) {
// username 要校验唯一
Map<String , String> map = new HashMap<>();
map.put("username" , createReqVO.getUsername());
this.validateMailAccountOnly(map);
MailAccountDO mailAccountDO = MailAccountConvert.INSTANCE.convert(createReqVO);
mailAccountMapper.insert(mailAccountDO);
return mailAccountDO.getId();
}
@Override
public void update(MailAccountUpdateReqVO updateReqVO) {
// username 要校验唯一
Map<String , String> map = new HashMap<>();
map.put("username" , updateReqVO.getUsername());
this.validateMailAccountOnly(map);
MailAccountDO mailAccountDO = MailAccountConvert.INSTANCE.convert(updateReqVO);
// 校验是否存在
this.validateMailAccountExists(mailAccountDO.getId());
mailAccountMapper.updateById(mailAccountDO);
}
@Override
public void delete(Long id) {
// 校验是否存在
this.validateMailAccountExists(id);
mailAccountMapper.deleteById(id);
}
@Override
public MailAccountDO getMailAccount(Long id) {
return mailAccountMapper.selectById(id);
}
@Override
public PageResult<MailAccountDO> getMailAccountPage(MailAccountPageReqVO pageReqVO) {
return mailAccountMapper.selectPage(pageReqVO);
}
@Override
public List<MailAccountDO> getMailAccountList() {
return mailAccountMapper.selectList();
}
private void validateMailAccountExists(Long id) {
if (mailAccountMapper.selectById(id) == null) {
throw exception(MAIL_ACCOUNT_NOT_EXISTS);
}
}
private void validateMailAccountOnly(Map params){
QueryWrapper queryWrapper = new QueryWrapper<MailAccountDO>();
params.forEach((k , v)->{
queryWrapper.like(k , v);
});
if (mailAccountMapper.selectOne(queryWrapper) != null) {
throw exception(MAIL_ACCOUNT_EXISTS);
}
}
}

View File

@ -1,18 +1,18 @@
package cn.iocoder.yudao.module.system.service.mail.impl;
import cn.iocoder.yudao.module.system.service.mail.SystemMailLogService;
import org.springframework.stereotype.Service;
/**
* <p>
* 服务实现类
* </p>
*
* @author wangjingyi
* @since 2022-03-21
*/
@Service
public class SystemMailLogServiceImpl implements SystemMailLogService {
}
package cn.iocoder.yudao.module.system.service.mail.impl;
import cn.iocoder.yudao.module.system.service.mail.MailLogService;
import org.springframework.stereotype.Service;
/**
* <p>
* 服务实现类
* </p>
*
* @author wangjingyi
* @since 2022-03-21
*/
@Service
public class MailLogServiceImpl implements MailLogService {
}

View File

@ -1,18 +1,18 @@
package cn.iocoder.yudao.module.system.service.mail.impl;
import cn.iocoder.yudao.module.system.service.mail.SystemMailTempleService;
import org.springframework.stereotype.Service;
/**
* <p>
* 服务实现类
* </p>
*
* @author wangjingyi
* @since 2022-03-21
*/
@Service
public class SystemMailTempleServiceImpl implements SystemMailTempleService {
}
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 {
}

View File

@ -1,73 +0,0 @@
package cn.iocoder.yudao.module.system.service.mail.impl;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.system.controller.admin.mail.vo.account.SystemMailAccountBaseVO;
import cn.iocoder.yudao.module.system.convert.mail.SystemMailAccountConvert;
import cn.iocoder.yudao.module.system.dal.dataobject.mail.SystemMailAccountDO;
import cn.iocoder.yudao.module.system.dal.mysql.mail.SystemMailAccountMapper;
import cn.iocoder.yudao.module.system.service.mail.SystemMailAccountService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
// TODO @ジョイイ类注释应该是 邮箱账号 Service 实现类
/**
* <p>
* 服务实现类
* </p>
*
* @author wangjingyi
* @since 2022-03-21
*/
@Service
public class SystemMailAccountServiceImpl implements SystemMailAccountService {
// TODO @ジョイイ private
@Resource
SystemMailAccountMapper systemMailAccountMapper; // TODO @ジョイイ 变量和方法要空一行
@Override
public Long create(SystemMailAccountBaseVO baseVO) {
// TODO @ジョイイ username 要校验唯一
SystemMailAccountDO systemMailAccountDO = SystemMailAccountConvert.INSTANCE.convert(baseVO);
systemMailAccountMapper.insert(systemMailAccountDO);
return systemMailAccountDO.getId();
}
// TODO @ジョイイ 不用返回值void 即可
@Override
public String update(SystemMailAccountBaseVO baseVO) {
// TODO @ジョイイ username 要校验唯一
// TODO @ジョイイ 校验是否存在
SystemMailAccountDO systemMailAccountDO = SystemMailAccountConvert.INSTANCE.convert(baseVO);
systemMailAccountMapper.updateById(systemMailAccountDO);
return null;
}
// TODO @ジョイイ 不用返回值void 即可
@Override
public String delete(SystemMailAccountBaseVO baseVO) {
// TODO @ジョイイ 校验是否存在
SystemMailAccountDO systemMailAccountDO = SystemMailAccountConvert.INSTANCE.convert(baseVO);
systemMailAccountMapper.deleteById(systemMailAccountDO);
return null;
}
@Override
public SystemMailAccountDO getMailAccount(Long id) {
return systemMailAccountMapper.selectById(id);
}
@Override
public PageResult<SystemMailAccountDO> getMailAccountPage(PageParam pageParam) {
return systemMailAccountMapper.selectPage(pageParam);
}
@Override
public List<SystemMailAccountDO> getMailAccountList() {
return systemMailAccountMapper.selectList();
}
}