邮箱账号管理

This commit is contained in:
wangjingyi 2022-03-23 20:59:46 +08:00
parent d2075d5c18
commit 3b42b70610
17 changed files with 572 additions and 0 deletions

View File

@ -0,0 +1,95 @@
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.controller.admin.sms.vo.channel.SmsChannelCreateReqVO;
import cn.iocoder.yudao.module.system.controller.admin.sms.vo.channel.SmsChannelPageReqVO;
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.convert.mail.SystemMailAccountConvert;
import cn.iocoder.yudao.module.system.convert.sms.SmsChannelConvert;
import cn.iocoder.yudao.module.system.dal.dataobject.mail.SystemMailAccountDO;
import cn.iocoder.yudao.module.system.dal.dataobject.sms.SmsChannelDO;
import cn.iocoder.yudao.module.system.service.mail.SystemMailAccountService;
import cn.iocoder.yudao.module.system.service.sms.SmsChannelService;
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;
/**
* <p>
* 前端控制器
* </p>
*
* @author wangjingyi
* @since 2022-03-21
*/
@Api(tags = "管理后台 - 邮件模板")
@RestController
@RequestMapping("/system-mail-account")
public class SystemMailAccountController {
@Resource
private SystemMailAccountService systemMailAccountService;
@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);
}
@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));
}
@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

@ -0,0 +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 {
}

View File

@ -0,0 +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 {
}

View File

@ -0,0 +1,26 @@
package cn.iocoder.yudao.module.system.controller.admin.mail.vo.account;
import com.baomidou.mybatisplus.annotation.TableField;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
public class SystemMailAccountBaseVO {
@ApiModelProperty(value = "来源" , required = true , example = "yudaoyuanma")
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 Integer sslEnable;
}

View File

@ -0,0 +1,25 @@
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

@ -0,0 +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 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;
}

View File

@ -0,0 +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;
}

View File

@ -0,0 +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;
}

View File

@ -0,0 +1,28 @@
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.controller.admin.sms.vo.channel.SmsChannelPageReqVO;
import cn.iocoder.yudao.module.system.dal.dataobject.mail.SystemMailAccountDO;
import cn.iocoder.yudao.module.system.dal.dataobject.sms.SmsChannelDO;
import org.apache.ibatis.annotations.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,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> {
}

View File

@ -0,0 +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> {
}

View File

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

View File

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

View File

@ -0,0 +1,63 @@
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;
/**
* <p>
* 服务实现类
* </p>
*
* @author wangjingyi
* @since 2022-03-21
*/
@Service
public class SystemMailAccountServiceImpl implements SystemMailAccountService {
@Resource
SystemMailAccountMapper systemMailAccountMapper;
@Override
public Long create(SystemMailAccountBaseVO baseVO) {
SystemMailAccountDO systemMailAccountDO = SystemMailAccountConvert.INSTANCE.convert(baseVO);
systemMailAccountMapper.insert(systemMailAccountDO);
return systemMailAccountDO.getId();
}
@Override
public String update(SystemMailAccountBaseVO baseVO) {
SystemMailAccountDO systemMailAccountDO = SystemMailAccountConvert.INSTANCE.convert(baseVO);
systemMailAccountMapper.updateById(systemMailAccountDO);
return null;
}
@Override
public String delete(SystemMailAccountBaseVO baseVO) {
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();
}
}

View File

@ -0,0 +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 {
}

View File

@ -0,0 +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 {
}