Commit de10aa6ab2b43e7b26e2390320d5f076ec602973
1 parent
54ad3045
邮箱日志功能
Showing
11 changed files
with
256 additions
and
14 deletions
yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/controller/admin/mail/MailLogController.java
| 1 | 1 | package cn.iocoder.yudao.module.system.controller.admin.mail; |
| 2 | 2 | |
| 3 | 3 | |
| 4 | +import cn.iocoder.yudao.framework.common.pojo.CommonResult; | |
| 5 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 6 | +import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; | |
| 7 | +import cn.iocoder.yudao.module.system.controller.admin.mail.vo.log.*; | |
| 8 | +import cn.iocoder.yudao.module.system.convert.mail.MailLogConvert; | |
| 9 | +import cn.iocoder.yudao.module.system.dal.dataobject.mail.MailLogDO; | |
| 10 | +import cn.iocoder.yudao.module.system.service.mail.MailLogService; | |
| 11 | +import io.swagger.annotations.ApiOperation; | |
| 12 | +import org.springframework.beans.factory.annotation.Autowired; | |
| 13 | +import org.springframework.security.access.prepost.PreAuthorize; | |
| 14 | +import org.springframework.web.bind.annotation.GetMapping; | |
| 4 | 15 | import org.springframework.web.bind.annotation.RequestMapping; |
| 5 | 16 | |
| 6 | 17 | import org.springframework.web.bind.annotation.RestController; |
| 7 | 18 | |
| 19 | +import javax.servlet.http.HttpServletResponse; | |
| 20 | +import javax.validation.Valid; | |
| 21 | + | |
| 22 | +import java.io.IOException; | |
| 23 | +import java.util.List; | |
| 24 | + | |
| 25 | +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | |
| 26 | + | |
| 8 | 27 | /** |
| 9 | 28 | * <p> |
| 10 | - * 前端控制器 | |
| 29 | + * 邮箱日志功能 | |
| 11 | 30 | * </p> |
| 12 | 31 | * |
| 13 | 32 | * @author wangjingyi |
| 14 | 33 | * @since 2022-03-21 |
| 15 | 34 | */ |
| 16 | 35 | @RestController |
| 17 | -@RequestMapping("/system-mail-log") | |
| 36 | +@RequestMapping("/system/mail-log") | |
| 18 | 37 | public class MailLogController { |
| 38 | + @Autowired | |
| 39 | + private MailLogService mailLogService; | |
| 40 | + | |
| 41 | + @GetMapping("/page") | |
| 42 | + @ApiOperation("获得邮箱日志分页") | |
| 43 | + @PreAuthorize("@ss.hasPermission('system:mail-log:query')") | |
| 44 | + public CommonResult<PageResult<MailLogRespVO>> getMailLogPage(@Valid MailLogPageReqVO pageVO) { | |
| 45 | + PageResult<MailLogDO> pageResult = mailLogService.getMailLogPage(pageVO); | |
| 46 | + return success(MailLogConvert.INSTANCE.convertPage(pageResult)); | |
| 47 | + } | |
| 19 | 48 | |
| 49 | + @GetMapping("/export-excel") | |
| 50 | + @ApiOperation("导出邮箱日志Excel") | |
| 51 | + @PreAuthorize("@ss.hasPermission('system:mail-log:export')") | |
| 52 | + public void exportMailLogExcel(@Valid MailLogExportReqVO exportReqVO , | |
| 53 | + HttpServletResponse response) throws IOException { | |
| 54 | + List<MailLogDO> list = mailLogService.getMailLogList(exportReqVO); | |
| 55 | + // 导出 Excel | |
| 56 | + List<MailLogExcelVO> datas = MailLogConvert.INSTANCE.convertList(list); | |
| 57 | + ExcelUtils.write(response, "邮箱日志.xls", "数据", MailLogExcelVO.class, datas); | |
| 58 | + } | |
| 20 | 59 | } | ... | ... |
yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/controller/admin/mail/vo/log/MailLogBaseVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.system.controller.admin.mail.vo.log; | |
| 2 | + | |
| 3 | +import com.baomidou.mybatisplus.annotation.TableField; | |
| 4 | +import com.baomidou.mybatisplus.annotation.TableId; | |
| 5 | +import io.swagger.annotations.ApiModelProperty; | |
| 6 | +import org.springframework.format.annotation.DateTimeFormat; | |
| 7 | + | |
| 8 | +import java.sql.Timestamp; | |
| 9 | + | |
| 10 | +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; | |
| 11 | + | |
| 12 | +public class MailLogBaseVO { | |
| 13 | + | |
| 14 | + @ApiModelProperty(value = "邮箱" , required = false , example = "yudaoyuanma@123.com") | |
| 15 | + private String from; | |
| 16 | + | |
| 17 | + @ApiModelProperty(value = "模版编号" , required = false , example = "templeId") | |
| 18 | + private String templeId; | |
| 19 | + | |
| 20 | + @ApiModelProperty(value = "模版code" , required = false , example = "templeCode") | |
| 21 | + private String templeCode; | |
| 22 | + | |
| 23 | + @ApiModelProperty(value = "标题" , required = false , example = "芋道源码") | |
| 24 | + private String title; | |
| 25 | + | |
| 26 | + @ApiModelProperty(value = "内容" , required = false , example = "遇到源码") | |
| 27 | + private String content; | |
| 28 | + | |
| 29 | + @ApiModelProperty(value = "收件人" , required = false , example = "yudaoyuanma@456.com") | |
| 30 | + private String to; | |
| 31 | + | |
| 32 | + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | |
| 33 | + @ApiModelProperty(value = "发送时间" , required = false , example = "2022-03-26 03:45:20") | |
| 34 | + private Timestamp sendTime; | |
| 35 | + | |
| 36 | + @ApiModelProperty(value = "发送状态" , required = false , example = "1") | |
| 37 | + private Boolean sendStatus; | |
| 38 | + | |
| 39 | + @ApiModelProperty(value = "发送结果" , required = false , example = "yudaoyuanma@123.com") | |
| 40 | + private String sendResult; | |
| 41 | + | |
| 42 | +} | ... | ... |
yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/controller/admin/mail/vo/log/MailLogExcelVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.system.controller.admin.mail.vo.log; | |
| 2 | + | |
| 3 | +import com.alibaba.excel.annotation.ExcelProperty; | |
| 4 | +import org.springframework.format.annotation.DateTimeFormat; | |
| 5 | + | |
| 6 | +import java.sql.Timestamp; | |
| 7 | + | |
| 8 | +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; | |
| 9 | + | |
| 10 | +public class MailLogExcelVO { | |
| 11 | + | |
| 12 | + @ExcelProperty(value = "邮箱" ) | |
| 13 | + private String from; | |
| 14 | + | |
| 15 | + @ExcelProperty(value = "模版编号" ) | |
| 16 | + private String templeCode; | |
| 17 | + | |
| 18 | + @ExcelProperty(value = "标题") | |
| 19 | + private String title; | |
| 20 | + | |
| 21 | + @ExcelProperty(value = "内容") | |
| 22 | + private String content; | |
| 23 | + | |
| 24 | + @ExcelProperty(value = "收件人" ) | |
| 25 | + private String to; | |
| 26 | + | |
| 27 | + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | |
| 28 | + @ExcelProperty(value = "发送时间" ) | |
| 29 | + private Timestamp sendTime; | |
| 30 | + | |
| 31 | + @ExcelProperty(value = "发送状态") | |
| 32 | + private Boolean sendStatus; | |
| 33 | + | |
| 34 | + @ExcelProperty(value = "发送结果") | |
| 35 | + private String sendResult; | |
| 36 | + | |
| 37 | +} | ... | ... |
yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/controller/admin/mail/vo/log/MailLogExportReqVO.java
0 → 100644
yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/controller/admin/mail/vo/log/MailLogPageReqVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.system.controller.admin.mail.vo.log; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.common.pojo.PageParam; | |
| 4 | +import io.swagger.annotations.ApiModelProperty; | |
| 5 | +import lombok.Data; | |
| 6 | +import org.springframework.format.annotation.DateTimeFormat; | |
| 7 | + | |
| 8 | +import java.sql.Timestamp; | |
| 9 | + | |
| 10 | +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; | |
| 11 | +@Data | |
| 12 | +public class MailLogPageReqVO extends PageParam { | |
| 13 | + @ApiModelProperty(value = "邮箱" , required = false , example = "yudaoyuanma@123.com") | |
| 14 | + private String from; | |
| 15 | + | |
| 16 | + @ApiModelProperty(value = "模版编号" , required = false , example = "templeId") | |
| 17 | + private String templeId; | |
| 18 | + | |
| 19 | + @ApiModelProperty(value = "模版code" , required = false , example = "templeCode") | |
| 20 | + private String templeCode; | |
| 21 | + | |
| 22 | + @ApiModelProperty(value = "标题" , required = false , example = "芋道源码") | |
| 23 | + private String title; | |
| 24 | + | |
| 25 | + @ApiModelProperty(value = "内容" , required = false , example = "遇到源码") | |
| 26 | + private String content; | |
| 27 | + | |
| 28 | + @ApiModelProperty(value = "收件人" , required = false , example = "yudaoyuanma@456.com") | |
| 29 | + private String to; | |
| 30 | + | |
| 31 | + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | |
| 32 | + @ApiModelProperty(value = "发送时间" , required = false , example = "2022-03-26 03:45:20") | |
| 33 | + private Timestamp sendTime; | |
| 34 | + | |
| 35 | + @ApiModelProperty(value = "发送状态" , required = false , example = "1") | |
| 36 | + private Boolean sendStatus; | |
| 37 | + | |
| 38 | + @ApiModelProperty(value = "发送结果" , required = false , example = "yudaoyuanma@123.com") | |
| 39 | + private String sendResult; | |
| 40 | +} | ... | ... |
yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/controller/admin/mail/vo/log/MailLogRespVO.java
0 → 100644
yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/convert/mail/MailLogConvert.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.system.convert.mail; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 4 | +import cn.iocoder.yudao.module.system.controller.admin.mail.vo.log.MailLogExcelVO; | |
| 5 | +import cn.iocoder.yudao.module.system.controller.admin.mail.vo.log.MailLogRespVO; | |
| 6 | +import cn.iocoder.yudao.module.system.dal.dataobject.mail.MailLogDO; | |
| 7 | +import org.mapstruct.Mapper; | |
| 8 | +import org.mapstruct.factory.Mappers; | |
| 9 | + | |
| 10 | +import java.util.List; | |
| 11 | + | |
| 12 | +@Mapper | |
| 13 | +public interface MailLogConvert { | |
| 14 | + MailLogConvert INSTANCE = Mappers.getMapper(MailLogConvert.class); | |
| 15 | + | |
| 16 | + PageResult<MailLogRespVO> convertPage(PageResult<MailLogDO> pageResult); | |
| 17 | + | |
| 18 | + List<MailLogExcelVO> convertList(List<MailLogDO> list); | |
| 19 | +} | ... | ... |
yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/mail/MailLogDO.java
| ... | ... | @@ -36,6 +36,9 @@ public class MailLogDO extends BaseDO implements Serializable { |
| 36 | 36 | @TableField("from") |
| 37 | 37 | private String from; |
| 38 | 38 | |
| 39 | + @TableField("temple_id") | |
| 40 | + private String templeId; | |
| 41 | + | |
| 39 | 42 | @TableField("temple_code") |
| 40 | 43 | private String templeCode; |
| 41 | 44 | |
| ... | ... | @@ -52,7 +55,7 @@ public class MailLogDO extends BaseDO implements Serializable { |
| 52 | 55 | private Timestamp sendTime; |
| 53 | 56 | |
| 54 | 57 | @TableField("sendStatus") |
| 55 | - private String sendStatus; | |
| 58 | + private Boolean sendStatus; | |
| 56 | 59 | |
| 57 | 60 | @TableField("sendResult") |
| 58 | 61 | private String sendResult; | ... | ... |
yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/mail/MailLogMapper.java
| 1 | 1 | package cn.iocoder.yudao.module.system.dal.mysql.mail; |
| 2 | 2 | |
| 3 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 4 | +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; | |
| 5 | +import cn.iocoder.yudao.framework.mybatis.core.query.QueryWrapperX; | |
| 6 | +import cn.iocoder.yudao.module.system.controller.admin.mail.vo.log.MailLogExportReqVO; | |
| 7 | +import cn.iocoder.yudao.module.system.controller.admin.mail.vo.log.MailLogPageReqVO; | |
| 3 | 8 | import cn.iocoder.yudao.module.system.dal.dataobject.mail.MailLogDO; |
| 4 | -import com.baomidou.mybatisplus.core.mapper.BaseMapper; | |
| 5 | 9 | |
| 6 | -/** | |
| 7 | - * <p> | |
| 8 | - * Mapper 接口 | |
| 9 | - * </p> | |
| 10 | - * | |
| 11 | - * @author wangjingyi | |
| 12 | - * @since 2022-03-21 | |
| 13 | - */ | |
| 14 | -public interface MailLogMapper extends BaseMapper<MailLogDO> { | |
| 10 | +import java.util.List; | |
| 15 | 11 | |
| 12 | +public interface MailLogMapper extends BaseMapperX<MailLogDO> { | |
| 13 | + | |
| 14 | + default PageResult<MailLogDO> selectPage(MailLogPageReqVO pageVO){ | |
| 15 | + return selectPage(pageVO , new QueryWrapperX<MailLogDO>() | |
| 16 | + .eqIfPresent("from", pageVO.getFrom()) | |
| 17 | + .eqIfPresent("templeCode", pageVO.getTempleCode()) | |
| 18 | + .likeIfPresent("title" , pageVO.getTitle()) | |
| 19 | + .likeIfPresent("content" , pageVO.getContent()) | |
| 20 | + .eqIfPresent("to", pageVO.getTo()) | |
| 21 | + .eqIfPresent("sendTime" , pageVO.getSendTime()) | |
| 22 | + .eqIfPresent("sendStatus" , pageVO.getSendStatus()) | |
| 23 | + .eqIfPresent("sendResult" , pageVO.getSendResult()) | |
| 24 | + .orderByDesc("sendTime") | |
| 25 | + ); | |
| 26 | + }; | |
| 27 | + | |
| 28 | + default List<MailLogDO> selectList(MailLogExportReqVO exportReqVO){ | |
| 29 | + return selectList(new QueryWrapperX<MailLogDO>() | |
| 30 | + .eqIfPresent("from", exportReqVO.getFrom()) | |
| 31 | + .eqIfPresent("templeCode", exportReqVO.getTempleCode()) | |
| 32 | + .likeIfPresent("title" , exportReqVO.getTitle()) | |
| 33 | + .likeIfPresent("content" , exportReqVO.getContent()) | |
| 34 | + .eqIfPresent("to", exportReqVO.getTo()) | |
| 35 | + .eqIfPresent("sendTime" , exportReqVO.getSendTime()) | |
| 36 | + .eqIfPresent("sendStatus" , exportReqVO.getSendStatus()) | |
| 37 | + .eqIfPresent("sendResult" , exportReqVO.getSendResult()) | |
| 38 | + .orderByDesc("sendTime") | |
| 39 | + ); | |
| 40 | + }; | |
| 16 | 41 | } | ... | ... |
yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/service/mail/MailLogService.java
| 1 | 1 | package cn.iocoder.yudao.module.system.service.mail; |
| 2 | 2 | |
| 3 | 3 | |
| 4 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 5 | +import cn.iocoder.yudao.module.system.controller.admin.mail.vo.log.MailLogExportReqVO; | |
| 6 | +import cn.iocoder.yudao.module.system.controller.admin.mail.vo.log.MailLogPageReqVO; | |
| 7 | +import cn.iocoder.yudao.module.system.dal.dataobject.mail.MailLogDO; | |
| 8 | + | |
| 9 | +import java.util.List; | |
| 10 | + | |
| 4 | 11 | /** |
| 5 | 12 | * <p> |
| 6 | 13 | * 服务类 |
| ... | ... | @@ -11,4 +18,7 @@ package cn.iocoder.yudao.module.system.service.mail; |
| 11 | 18 | */ |
| 12 | 19 | public interface MailLogService { |
| 13 | 20 | |
| 21 | + PageResult<MailLogDO> getMailLogPage(MailLogPageReqVO pageVO); | |
| 22 | + | |
| 23 | + List<MailLogDO> getMailLogList(MailLogExportReqVO exportReqVO); | |
| 14 | 24 | } | ... | ... |
yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/service/mail/impl/MailLogServiceImpl.java
| 1 | 1 | package cn.iocoder.yudao.module.system.service.mail.impl; |
| 2 | 2 | |
| 3 | 3 | |
| 4 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 5 | +import cn.iocoder.yudao.module.system.controller.admin.mail.vo.log.MailLogExportReqVO; | |
| 6 | +import cn.iocoder.yudao.module.system.controller.admin.mail.vo.log.MailLogPageReqVO; | |
| 7 | +import cn.iocoder.yudao.module.system.dal.dataobject.mail.MailLogDO; | |
| 8 | +import cn.iocoder.yudao.module.system.dal.mysql.mail.MailLogMapper; | |
| 4 | 9 | import cn.iocoder.yudao.module.system.service.mail.MailLogService; |
| 10 | +import org.springframework.beans.factory.annotation.Autowired; | |
| 5 | 11 | import org.springframework.stereotype.Service; |
| 6 | 12 | |
| 13 | +import java.util.List; | |
| 14 | + | |
| 7 | 15 | /** |
| 8 | 16 | * <p> |
| 9 | - * 服务实现类 | |
| 17 | + * 邮箱日志实现类 | |
| 10 | 18 | * </p> |
| 11 | 19 | * |
| 12 | 20 | * @author wangjingyi |
| ... | ... | @@ -14,5 +22,16 @@ import org.springframework.stereotype.Service; |
| 14 | 22 | */ |
| 15 | 23 | @Service |
| 16 | 24 | public class MailLogServiceImpl implements MailLogService { |
| 25 | + @Autowired | |
| 26 | + MailLogMapper mailLogMapper; | |
| 27 | + | |
| 28 | + @Override | |
| 29 | + public PageResult<MailLogDO> getMailLogPage(MailLogPageReqVO pageVO) { | |
| 30 | + return mailLogMapper.selectPage(pageVO); | |
| 31 | + } | |
| 17 | 32 | |
| 33 | + @Override | |
| 34 | + public List<MailLogDO> getMailLogList(MailLogExportReqVO exportReqVO) { | |
| 35 | + return mailLogMapper.selectList(exportReqVO); | |
| 36 | + } | |
| 18 | 37 | } | ... | ... |