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 2bc87c6ac..6615448d3 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 @@ -1,20 +1,59 @@ 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.framework.excel.core.util.ExcelUtils; +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.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; + +import java.io.IOException; +import java.util.List; + +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; + /** *

- * 前端控制器 + * 邮箱日志功能 *

* * @author wangjingyi * @since 2022-03-21 */ @RestController -@RequestMapping("/system-mail-log") +@RequestMapping("/system/mail-log") public class MailLogController { + @Autowired + private MailLogService mailLogService; + @GetMapping("/page") + @ApiOperation("获得邮箱日志分页") + @PreAuthorize("@ss.hasPermission('system:mail-log:query')") + public CommonResult> getMailLogPage(@Valid MailLogPageReqVO pageVO) { + PageResult pageResult = mailLogService.getMailLogPage(pageVO); + return success(MailLogConvert.INSTANCE.convertPage(pageResult)); + } + + @GetMapping("/export-excel") + @ApiOperation("导出邮箱日志Excel") + @PreAuthorize("@ss.hasPermission('system:mail-log:export')") + public void exportMailLogExcel(@Valid MailLogExportReqVO exportReqVO , + HttpServletResponse response) throws IOException { + List list = mailLogService.getMailLogList(exportReqVO); + // 导出 Excel + List datas = MailLogConvert.INSTANCE.convertList(list); + ExcelUtils.write(response, "邮箱日志.xls", "数据", MailLogExcelVO.class, datas); + } } 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 new file mode 100644 index 000000000..80b6e8828 --- /dev/null +++ b/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/controller/admin/mail/vo/log/MailLogBaseVO.java @@ -0,0 +1,42 @@ +package cn.iocoder.yudao.module.system.controller.admin.mail.vo.log; + +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import io.swagger.annotations.ApiModelProperty; +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; + +public class MailLogBaseVO { + + @ApiModelProperty(value = "邮箱" , required = false , example = "yudaoyuanma@123.com") + private String from; + + @ApiModelProperty(value = "模版编号" , required = false , example = "templeId") + private String templeId; + + @ApiModelProperty(value = "模版code" , required = false , example = "templeCode") + private String templeCode; + + @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/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 new file mode 100644 index 000000000..e6eee9f19 --- /dev/null +++ b/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/controller/admin/mail/vo/log/MailLogExcelVO.java @@ -0,0 +1,37 @@ +package cn.iocoder.yudao.module.system.controller.admin.mail.vo.log; + +import com.alibaba.excel.annotation.ExcelProperty; +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; + +public class MailLogExcelVO { + + @ExcelProperty(value = "邮箱" ) + private String from; + + @ExcelProperty(value = "模版编号" ) + private String templeCode; + + @ExcelProperty(value = "标题") + private String title; + + @ExcelProperty(value = "内容") + private String content; + + @ExcelProperty(value = "收件人" ) + private String to; + + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + @ExcelProperty(value = "发送时间" ) + private Timestamp sendTime; + + @ExcelProperty(value = "发送状态") + private Boolean sendStatus; + + @ExcelProperty(value = "发送结果") + 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/log/MailLogExportReqVO.java b/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/controller/admin/mail/vo/log/MailLogExportReqVO.java new file mode 100644 index 000000000..0c8696980 --- /dev/null +++ b/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/controller/admin/mail/vo/log/MailLogExportReqVO.java @@ -0,0 +1,4 @@ +package cn.iocoder.yudao.module.system.controller.admin.mail.vo.log; + +public class MailLogExportReqVO extends MailLogPageReqVO{ +} 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 new file mode 100644 index 000000000..a12953af4 --- /dev/null +++ b/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/controller/admin/mail/vo/log/MailLogPageReqVO.java @@ -0,0 +1,40 @@ +package cn.iocoder.yudao.module.system.controller.admin.mail.vo.log; + +import cn.iocoder.yudao.framework.common.pojo.PageParam; +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 MailLogPageReqVO extends PageParam { + @ApiModelProperty(value = "邮箱" , required = false , example = "yudaoyuanma@123.com") + private String from; + + @ApiModelProperty(value = "模版编号" , required = false , example = "templeId") + private String templeId; + + @ApiModelProperty(value = "模版code" , required = false , example = "templeCode") + private String templeCode; + + @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/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 new file mode 100644 index 000000000..9bbf35179 --- /dev/null +++ b/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/controller/admin/mail/vo/log/MailLogRespVO.java @@ -0,0 +1,4 @@ +package cn.iocoder.yudao.module.system.controller.admin.mail.vo.log; + +public class MailLogRespVO extends MailLogBaseVO { +} diff --git a/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/convert/mail/MailLogConvert.java b/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/convert/mail/MailLogConvert.java new file mode 100644 index 000000000..417550886 --- /dev/null +++ b/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/convert/mail/MailLogConvert.java @@ -0,0 +1,19 @@ +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.log.MailLogExcelVO; +import cn.iocoder.yudao.module.system.controller.admin.mail.vo.log.MailLogRespVO; +import cn.iocoder.yudao.module.system.dal.dataobject.mail.MailLogDO; +import org.mapstruct.Mapper; +import org.mapstruct.factory.Mappers; + +import java.util.List; + +@Mapper +public interface MailLogConvert { + MailLogConvert INSTANCE = Mappers.getMapper(MailLogConvert.class); + + PageResult convertPage(PageResult pageResult); + + List convertList(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 0d435a8c3..ae3d603da 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 @@ -36,6 +36,9 @@ public class MailLogDO extends BaseDO implements Serializable { @TableField("from") private String from; + @TableField("temple_id") + private String templeId; + @TableField("temple_code") private String templeCode; @@ -52,7 +55,7 @@ public class MailLogDO extends BaseDO implements Serializable { private Timestamp sendTime; @TableField("sendStatus") - private String sendStatus; + private Boolean sendStatus; @TableField("sendResult") private String sendResult; 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 2f6912812..51be49019 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 @@ -1,16 +1,41 @@ 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.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 com.baomidou.mybatisplus.core.mapper.BaseMapper; -/** - *

- * Mapper 接口 - *

- * - * @author wangjingyi - * @since 2022-03-21 - */ -public interface MailLogMapper extends BaseMapper { +import java.util.List; +public interface MailLogMapper extends BaseMapperX { + + default PageResult selectPage(MailLogPageReqVO pageVO){ + return selectPage(pageVO , new QueryWrapperX() + .eqIfPresent("from", pageVO.getFrom()) + .eqIfPresent("templeCode", pageVO.getTempleCode()) + .likeIfPresent("title" , pageVO.getTitle()) + .likeIfPresent("content" , pageVO.getContent()) + .eqIfPresent("to", pageVO.getTo()) + .eqIfPresent("sendTime" , pageVO.getSendTime()) + .eqIfPresent("sendStatus" , pageVO.getSendStatus()) + .eqIfPresent("sendResult" , pageVO.getSendResult()) + .orderByDesc("sendTime") + ); + }; + + default List selectList(MailLogExportReqVO exportReqVO){ + return selectList(new QueryWrapperX() + .eqIfPresent("from", exportReqVO.getFrom()) + .eqIfPresent("templeCode", exportReqVO.getTempleCode()) + .likeIfPresent("title" , exportReqVO.getTitle()) + .likeIfPresent("content" , exportReqVO.getContent()) + .eqIfPresent("to", exportReqVO.getTo()) + .eqIfPresent("sendTime" , exportReqVO.getSendTime()) + .eqIfPresent("sendStatus" , exportReqVO.getSendStatus()) + .eqIfPresent("sendResult" , exportReqVO.getSendResult()) + .orderByDesc("sendTime") + ); + }; } diff --git a/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/service/mail/MailLogService.java b/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/service/mail/MailLogService.java index d5442936f..79d38730d 100644 --- a/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/service/mail/MailLogService.java +++ b/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/service/mail/MailLogService.java @@ -1,6 +1,13 @@ 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.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 java.util.List; + /** *

* 服务类 @@ -11,4 +18,7 @@ package cn.iocoder.yudao.module.system.service.mail; */ public interface MailLogService { + PageResult getMailLogPage(MailLogPageReqVO pageVO); + + List getMailLogList(MailLogExportReqVO exportReqVO); } diff --git a/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/service/mail/impl/MailLogServiceImpl.java b/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/service/mail/impl/MailLogServiceImpl.java index af2ff6694..2daeeab3e 100644 --- a/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/service/mail/impl/MailLogServiceImpl.java +++ b/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/service/mail/impl/MailLogServiceImpl.java @@ -1,12 +1,20 @@ 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.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 cn.iocoder.yudao.module.system.dal.mysql.mail.MailLogMapper; import cn.iocoder.yudao.module.system.service.mail.MailLogService; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import java.util.List; + /** *

- * 服务实现类 + * 邮箱日志实现类 *

* * @author wangjingyi @@ -14,5 +22,16 @@ import org.springframework.stereotype.Service; */ @Service public class MailLogServiceImpl implements MailLogService { + @Autowired + MailLogMapper mailLogMapper; + @Override + public PageResult getMailLogPage(MailLogPageReqVO pageVO) { + return mailLogMapper.selectPage(pageVO); + } + + @Override + public List getMailLogList(MailLogExportReqVO exportReqVO) { + return mailLogMapper.selectList(exportReqVO); + } }