mirror of
https://gitee.com/hhyykk/ipms-sjy.git
synced 2025-02-08 14:44:57 +08:00
邮箱模块:完善 log 相关的逻辑
This commit is contained in:
parent
f9ab45df18
commit
525078abd3
@ -7,7 +7,7 @@ import lombok.Getter;
|
|||||||
* 邮件的发送状态枚举
|
* 邮件的发送状态枚举
|
||||||
*
|
*
|
||||||
* @author wangjingyi
|
* @author wangjingyi
|
||||||
* @date 2022/4/10 13:39
|
* @since 2022/4/10 13:39
|
||||||
*/
|
*/
|
||||||
@Getter
|
@Getter
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
|
@ -3,23 +3,20 @@ package cn.iocoder.yudao.module.system.controller.admin.mail;
|
|||||||
|
|
||||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
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.MailLogPageReqVO;
|
||||||
import cn.iocoder.yudao.module.system.controller.admin.mail.vo.log.*;
|
import cn.iocoder.yudao.module.system.controller.admin.mail.vo.log.MailLogRespVO;
|
||||||
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.Api;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
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.validation.Valid;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import javax.annotation.Resource;
|
||||||
import java.util.List;
|
import javax.validation.Valid;
|
||||||
|
|
||||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||||
|
|
||||||
@ -29,7 +26,7 @@ import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
|||||||
@RequestMapping("/system/mail-log")
|
@RequestMapping("/system/mail-log")
|
||||||
public class MailLogController {
|
public class MailLogController {
|
||||||
|
|
||||||
@Autowired
|
@Resource
|
||||||
private MailLogService mailLogService;
|
private MailLogService mailLogService;
|
||||||
|
|
||||||
@GetMapping("/page")
|
@GetMapping("/page")
|
||||||
@ -40,14 +37,4 @@ public class MailLogController {
|
|||||||
return success(MailLogConvert.INSTANCE.convertPage(pageResult));
|
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<MailLogDO> list = mailLogService.getMailLogList(exportReqVO);
|
|
||||||
// 导出 Excel
|
|
||||||
List<MailLogExcelVO> datas = MailLogConvert.INSTANCE.convertList(list);
|
|
||||||
ExcelUtils.write(response, "邮箱日志.xls", "数据", MailLogExcelVO.class, datas);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,46 +1,76 @@
|
|||||||
package cn.iocoder.yudao.module.system.controller.admin.mail.vo.log;
|
package cn.iocoder.yudao.module.system.controller.admin.mail.vo.log;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableField;
|
import lombok.*;
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
import java.util.*;
|
||||||
import io.swagger.annotations.ApiModel;
|
import java.time.LocalDateTime;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import java.time.LocalDateTime;
|
||||||
import lombok.Data;
|
import java.time.LocalDateTime;
|
||||||
|
import io.swagger.annotations.*;
|
||||||
|
import javax.validation.constraints.*;
|
||||||
import org.springframework.format.annotation.DateTimeFormat;
|
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;
|
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||||
|
|
||||||
@ApiModel("管理后台 - 邮箱日志基类 Base VO")
|
/**
|
||||||
|
* 邮件日志 Base VO,提供给添加、修改、详细的子 VO 使用
|
||||||
|
* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成
|
||||||
|
*/
|
||||||
@Data
|
@Data
|
||||||
public class MailLogBaseVO {
|
public class MailLogBaseVO {
|
||||||
|
|
||||||
@ApiModelProperty(value = "邮箱" , required = false , example = "yudaoyuanma@123.com")
|
@ApiModelProperty(value = "用户编号", example = "30883")
|
||||||
private String from;
|
private Long userId;
|
||||||
|
|
||||||
@ApiModelProperty(value = "模版编号" , required = false , example = "templeId")
|
@ApiModelProperty(value = "用户类型", example = "2", notes = "参见 UserTypeEnum 枚举")
|
||||||
private String templateId;
|
private Byte userType;
|
||||||
|
|
||||||
@ApiModelProperty(value = "模版code" , required = false , example = "templeCode")
|
@ApiModelProperty(value = "接收邮箱地址", required = true, example = "76854@qq.com")
|
||||||
|
@NotNull(message = "接收邮箱地址不能为空")
|
||||||
|
private String toMail;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "邮箱账号编号", required = true, example = "18107")
|
||||||
|
@NotNull(message = "邮箱账号编号不能为空")
|
||||||
|
private Long accountId;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "发送邮箱地址", required = true, example = "85757@qq.com")
|
||||||
|
@NotNull(message = "发送邮箱地址不能为空")
|
||||||
|
private String fromMail;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "模板编号", required = true, example = "5678")
|
||||||
|
@NotNull(message = "模板编号不能为空")
|
||||||
|
private Long templateId;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "模板编码", required = true, example = "test_01")
|
||||||
|
@NotNull(message = "模板编码不能为空")
|
||||||
private String templateCode;
|
private String templateCode;
|
||||||
|
|
||||||
@ApiModelProperty(value = "标题" , required = false , example = "芋道源码")
|
@ApiModelProperty(value = "模版发送人名称", example = "李四")
|
||||||
private String title;
|
private String templateNickname;
|
||||||
|
|
||||||
@ApiModelProperty(value = "内容" , required = false , example = "遇到源码")
|
@ApiModelProperty(value = "邮件标题", required = true, example = "测试标题")
|
||||||
private String content;
|
@NotNull(message = "邮件标题不能为空")
|
||||||
|
private String templateTitle;
|
||||||
|
|
||||||
@ApiModelProperty(value = "收件人" , required = false , example = "yudaoyuanma@456.com")
|
@ApiModelProperty(value = "邮件内容", required = true, example = "测试内容")
|
||||||
private String to;
|
@NotNull(message = "邮件内容不能为空")
|
||||||
|
private String templateContent;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "邮件参数", required = true)
|
||||||
|
@NotNull(message = "邮件参数不能为空")
|
||||||
|
private Map<String, Object> templateParams;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "发送状态", required = true, example = "1", notes = "参见 MailSendStatusEnum 枚举")
|
||||||
|
@NotNull(message = "发送状态不能为空")
|
||||||
|
private Byte sendStatus;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "发送时间")
|
||||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||||
@ApiModelProperty(value = "发送时间" , required = false , example = "2022-03-26 03:45:20")
|
private LocalDateTime sendTime;
|
||||||
private Timestamp sendTime;
|
|
||||||
|
|
||||||
@ApiModelProperty(value = "发送状态" , required = false , example = "1")
|
@ApiModelProperty(value = "发送返回的消息 ID", example = "28568")
|
||||||
private Boolean sendStatus;
|
private String sendMessageId;
|
||||||
|
|
||||||
@ApiModelProperty(value = "发送结果" , required = false , example = "yudaoyuanma@123.com")
|
@ApiModelProperty(value = "发送异常")
|
||||||
private String sendResult;
|
private String sendException;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,42 +0,0 @@
|
|||||||
package cn.iocoder.yudao.module.system.controller.admin.mail.vo.log;
|
|
||||||
|
|
||||||
import com.alibaba.excel.annotation.ExcelProperty;
|
|
||||||
import io.swagger.annotations.ApiModel;
|
|
||||||
import lombok.Data;
|
|
||||||
import org.springframework.format.annotation.DateTimeFormat;
|
|
||||||
|
|
||||||
import java.sql.Timestamp;
|
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
|
||||||
|
|
||||||
@ApiModel("管理后台 - 邮箱日志导出 Request VO")
|
|
||||||
@Data
|
|
||||||
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 Date sendTime;
|
|
||||||
|
|
||||||
@ExcelProperty(value = "发送状态")
|
|
||||||
private Integer sendStatus;
|
|
||||||
|
|
||||||
@ExcelProperty(value = "发送结果")
|
|
||||||
private String sendResult;
|
|
||||||
|
|
||||||
}
|
|
@ -1,9 +0,0 @@
|
|||||||
package cn.iocoder.yudao.module.system.controller.admin.mail.vo.log;
|
|
||||||
|
|
||||||
import io.swagger.annotations.ApiModel;
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
@ApiModel("管理后台 - 邮箱日志导出 Request VO")
|
|
||||||
@Data
|
|
||||||
public class MailLogExportReqVO extends MailLogPageReqVO {
|
|
||||||
}
|
|
@ -9,6 +9,7 @@ import lombok.ToString;
|
|||||||
import org.springframework.format.annotation.DateTimeFormat;
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
|
||||||
import java.sql.Timestamp;
|
import java.sql.Timestamp;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
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;
|
||||||
|
|
||||||
@ -18,33 +19,26 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_
|
|||||||
@ToString(callSuper = true)
|
@ToString(callSuper = true)
|
||||||
public class MailLogPageReqVO extends PageParam {
|
public class MailLogPageReqVO extends PageParam {
|
||||||
|
|
||||||
// TODO @wangjingyi:required 为 false 时,它是默认值,所以不用谢 DONE
|
@ApiModelProperty(value = "用户编号", example = "30883")
|
||||||
|
private Long userId;
|
||||||
|
|
||||||
@ApiModelProperty(value = "邮箱" , example = "yudaoyuanma@123.com")
|
@ApiModelProperty(value = "用户类型", example = "2", notes = "参见 UserTypeEnum 枚举")
|
||||||
private String from;
|
private Byte userType;
|
||||||
|
|
||||||
@ApiModelProperty(value = "模版编号" , required = false , example = "templeId")
|
@ApiModelProperty(value = "接收邮箱地址", example = "76854@qq.com", notes = "模糊匹配")
|
||||||
private String templateId;
|
private String toMail;
|
||||||
|
|
||||||
@ApiModelProperty(value = "模版code" , required = false , example = "templeCode")
|
@ApiModelProperty(value = "邮箱账号编号", example = "18107")
|
||||||
private String templateCode;
|
private Long accountId;
|
||||||
|
|
||||||
@ApiModelProperty(value = "标题" , required = false , example = "芋道源码")
|
@ApiModelProperty(value = "模板编号", example = "5678")
|
||||||
private String title;
|
private Long templateId;
|
||||||
|
|
||||||
@ApiModelProperty(value = "内容" , required = false , example = "遇到源码")
|
@ApiModelProperty(value = "发送状态", example = "1", notes = "参见 MailSendStatusEnum 枚举")
|
||||||
private String content;
|
private Integer sendStatus;
|
||||||
|
|
||||||
@ApiModelProperty(value = "收件人" , required = false , example = "yudaoyuanma@456.com")
|
|
||||||
private String to;
|
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "发送时间")
|
||||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||||
@ApiModelProperty(value = "发送时间" , required = false , example = "2022-03-26 03:45:20")
|
private LocalDateTime[] sendTime;
|
||||||
private Timestamp sendTime;
|
|
||||||
|
|
||||||
@ApiModelProperty(value = "发送状态" , required = false , example = "1")
|
|
||||||
private Boolean sendStatus;
|
|
||||||
|
|
||||||
@ApiModelProperty(value = "发送结果" , required = false , example = "yudaoyuanma@123.com")
|
|
||||||
private String sendResult;
|
|
||||||
}
|
}
|
||||||
|
@ -1,44 +1,19 @@
|
|||||||
package cn.iocoder.yudao.module.system.controller.admin.mail.vo.log;
|
package cn.iocoder.yudao.module.system.controller.admin.mail.vo.log;
|
||||||
|
|
||||||
import io.swagger.annotations.ApiModel;
|
import lombok.*;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import java.time.LocalDateTime;
|
||||||
import lombok.Data;
|
import io.swagger.annotations.*;
|
||||||
import org.springframework.format.annotation.DateTimeFormat;
|
|
||||||
|
|
||||||
import java.sql.Timestamp;
|
@ApiModel("管理后台 - 邮件日志 Response VO")
|
||||||
|
|
||||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
|
||||||
|
|
||||||
@ApiModel("管理后台 - 邮箱日志返回 Request VO")
|
|
||||||
@Data
|
@Data
|
||||||
public class MailLogRespVO {
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@ToString(callSuper = true)
|
||||||
|
public class MailLogRespVO extends MailLogBaseVO {
|
||||||
|
|
||||||
@ApiModelProperty(value = "邮箱" , required = false , example = "yudaoyuanma@123.com")
|
@ApiModelProperty(value = "编号", required = true, example = "31020")
|
||||||
private String from;
|
private Long id;
|
||||||
|
|
||||||
@ApiModelProperty(value = "模版编号" , required = false , example = "templeId")
|
@ApiModelProperty(value = "创建时间", required = true)
|
||||||
private String templateId;
|
private LocalDateTime createTime;
|
||||||
|
|
||||||
@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 Integer sendStatus;
|
|
||||||
|
|
||||||
@ApiModelProperty(value = "发送结果" , required = false , example = "yudaoyuanma@123.com")
|
|
||||||
private String sendResult;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,18 +1,16 @@
|
|||||||
package cn.iocoder.yudao.module.system.convert.mail;
|
package cn.iocoder.yudao.module.system.convert.mail;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
import cn.hutool.extra.mail.MailAccount;
|
import cn.hutool.extra.mail.MailAccount;
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
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.MailAccountBaseVO;
|
||||||
import cn.iocoder.yudao.module.system.controller.admin.mail.vo.account.MailAccountRespVO;
|
import cn.iocoder.yudao.module.system.controller.admin.mail.vo.account.MailAccountRespVO;
|
||||||
import cn.iocoder.yudao.module.system.controller.admin.mail.vo.account.MailAccountSimpleRespVO;
|
import cn.iocoder.yudao.module.system.controller.admin.mail.vo.account.MailAccountSimpleRespVO;
|
||||||
import cn.iocoder.yudao.module.system.dal.dataobject.mail.MailAccountDO;
|
import cn.iocoder.yudao.module.system.dal.dataobject.mail.MailAccountDO;
|
||||||
import cn.iocoder.yudao.module.system.mq.message.mail.MailSendMessage;
|
|
||||||
import org.mapstruct.Mapper;
|
import org.mapstruct.Mapper;
|
||||||
import org.mapstruct.factory.Mappers;
|
import org.mapstruct.factory.Mappers;
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
@Mapper
|
@Mapper
|
||||||
public interface MailAccountConvert {
|
public interface MailAccountConvert {
|
||||||
@ -27,25 +25,11 @@ public interface MailAccountConvert {
|
|||||||
|
|
||||||
List<MailAccountSimpleRespVO> convertList02(List<MailAccountDO> list);
|
List<MailAccountSimpleRespVO> convertList02(List<MailAccountDO> list);
|
||||||
|
|
||||||
// TODO 芋艿:改下
|
default MailAccount convert(MailAccountDO account, String nickname) {
|
||||||
default MailAccount convertAccount(MailSendMessage bean) {
|
String from = StrUtil.isNotEmpty(nickname) ? nickname + " <" + account.getMail() + ">" : account.getMail();
|
||||||
return new MailAccount()
|
return new MailAccount().setFrom(from).setAuth(true)
|
||||||
.setHost(bean.getHost())
|
.setUser(account.getUsername()).setPass(account.getPassword())
|
||||||
.setPort(bean.getPort())
|
.setHost(account.getHost()).setPort(account.getPort()).setSslEnable(account.getSslEnable());
|
||||||
.setAuth(true)
|
|
||||||
.setFrom(bean.getMail())
|
|
||||||
.setUser(bean.getUsername())
|
|
||||||
.setPass(bean.getPassword())
|
|
||||||
.setSslEnable(bean.getSslEnable());
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO 芋艿:改下
|
|
||||||
default Map<String, String> convertToMap(MailAccountDO mailAccountDO , String content) {
|
|
||||||
Map<String , String> map = new HashMap<>();
|
|
||||||
map.put("from_address" , mailAccountDO.getMail());
|
|
||||||
map.put("username" , mailAccountDO.getUsername());
|
|
||||||
map.put("content" , content);
|
|
||||||
return map;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,19 +1,16 @@
|
|||||||
package cn.iocoder.yudao.module.system.convert.mail;
|
package cn.iocoder.yudao.module.system.convert.mail;
|
||||||
|
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
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.controller.admin.mail.vo.log.MailLogRespVO;
|
||||||
import cn.iocoder.yudao.module.system.dal.dataobject.mail.MailLogDO;
|
import cn.iocoder.yudao.module.system.dal.dataobject.mail.MailLogDO;
|
||||||
import org.mapstruct.Mapper;
|
import org.mapstruct.Mapper;
|
||||||
import org.mapstruct.factory.Mappers;
|
import org.mapstruct.factory.Mappers;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@Mapper
|
@Mapper
|
||||||
public interface MailLogConvert {
|
public interface MailLogConvert {
|
||||||
|
|
||||||
MailLogConvert INSTANCE = Mappers.getMapper(MailLogConvert.class);
|
MailLogConvert INSTANCE = Mappers.getMapper(MailLogConvert.class);
|
||||||
|
|
||||||
PageResult<MailLogRespVO> convertPage(PageResult<MailLogDO> pageResult);
|
PageResult<MailLogRespVO> convertPage(PageResult<MailLogDO> pageResult);
|
||||||
|
|
||||||
List<MailLogExcelVO> convertList(List<MailLogDO> list);
|
|
||||||
}
|
}
|
||||||
|
@ -114,8 +114,8 @@ public class MailLogDO extends BaseDO implements Serializable {
|
|||||||
*/
|
*/
|
||||||
private String sendMessageId;
|
private String sendMessageId;
|
||||||
/**
|
/**
|
||||||
* 发送结果
|
* 发送异常
|
||||||
*/
|
*/
|
||||||
private String sendResult;
|
private String sendException;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -2,41 +2,25 @@ package cn.iocoder.yudao.module.system.dal.mysql.mail;
|
|||||||
|
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||||
import cn.iocoder.yudao.framework.mybatis.core.query.QueryWrapperX;
|
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||||
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 org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
@Mapper
|
@Mapper
|
||||||
public interface MailLogMapper extends BaseMapperX<MailLogDO> {
|
public interface MailLogMapper extends BaseMapperX<MailLogDO> {
|
||||||
|
|
||||||
default PageResult<MailLogDO> selectPage(MailLogPageReqVO pageVO){
|
default PageResult<MailLogDO> selectPage(MailLogPageReqVO reqVO) {
|
||||||
return selectPage(pageVO , new QueryWrapperX<MailLogDO>()
|
return selectPage(reqVO, new LambdaQueryWrapperX<MailLogDO>()
|
||||||
.eqIfPresent("from", pageVO.getFrom())
|
.eqIfPresent(MailLogDO::getUserId, reqVO.getUserId())
|
||||||
.eqIfPresent("templeCode", pageVO.getTemplateCode())
|
.eqIfPresent(MailLogDO::getUserType, reqVO.getUserType())
|
||||||
.likeIfPresent("title" , pageVO.getTitle())
|
.likeIfPresent(MailLogDO::getToMail, reqVO.getToMail())
|
||||||
.likeIfPresent("content" , pageVO.getContent())
|
.eqIfPresent(MailLogDO::getAccountId, reqVO.getAccountId())
|
||||||
.eqIfPresent("to", pageVO.getTo())
|
.likeIfPresent(MailLogDO::getFromMail, reqVO.getFromMail())
|
||||||
.eqIfPresent("sendTime" , pageVO.getSendTime())
|
.eqIfPresent(MailLogDO::getTemplateId, reqVO.getTemplateId())
|
||||||
.eqIfPresent("sendStatus" , pageVO.getSendStatus())
|
.eqIfPresent(MailLogDO::getSendStatus, reqVO.getSendStatus())
|
||||||
.eqIfPresent("sendResult" , pageVO.getSendResult())
|
.betweenIfPresent(MailLogDO::getSendTime, reqVO.getSendTime())
|
||||||
.orderByDesc("sendTime")
|
.orderByDesc(MailLogDO::getId));
|
||||||
);
|
}
|
||||||
};
|
|
||||||
|
|
||||||
default List<MailLogDO> selectList(MailLogExportReqVO exportReqVO){
|
|
||||||
return selectList(new QueryWrapperX<MailLogDO>()
|
|
||||||
.eqIfPresent("from", exportReqVO.getFrom())
|
|
||||||
.eqIfPresent("templeCode", exportReqVO.getTemplateCode())
|
|
||||||
.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")
|
|
||||||
);
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
@ -1,13 +1,11 @@
|
|||||||
package cn.iocoder.yudao.module.system.service.mail;
|
package cn.iocoder.yudao.module.system.service.mail;
|
||||||
|
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
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.controller.admin.mail.vo.log.MailLogPageReqVO;
|
||||||
import cn.iocoder.yudao.module.system.dal.dataobject.mail.MailAccountDO;
|
import cn.iocoder.yudao.module.system.dal.dataobject.mail.MailAccountDO;
|
||||||
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.dal.dataobject.mail.MailTemplateDO;
|
import cn.iocoder.yudao.module.system.dal.dataobject.mail.MailTemplateDO;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -26,42 +24,30 @@ public interface MailLogService {
|
|||||||
*/
|
*/
|
||||||
PageResult<MailLogDO> getMailLogPage(MailLogPageReqVO pageVO);
|
PageResult<MailLogDO> getMailLogPage(MailLogPageReqVO pageVO);
|
||||||
|
|
||||||
/**
|
|
||||||
* 邮件日志数组信息
|
|
||||||
*
|
|
||||||
* @param exportReqVO 导出筛选请求
|
|
||||||
* @return 导出的日志数据
|
|
||||||
*/
|
|
||||||
List<MailLogDO> getMailLogList(MailLogExportReqVO exportReqVO);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建邮件日志
|
* 创建邮件日志
|
||||||
*
|
*
|
||||||
* @param userId 用户编码
|
* @param userId 用户编码
|
||||||
* @param userType 用户类型
|
* @param userType 用户类型
|
||||||
* @param to 收件人
|
* @param toMail 收件人邮件
|
||||||
* @param mailAccountDO 邮件账号信息
|
* @param account 邮件账号信息
|
||||||
* @param template 模版信息
|
* @param template 模版信息
|
||||||
* @param templateContent 模版内容
|
* @param templateContent 模版内容
|
||||||
* @param templateParams 模版参数
|
* @param templateParams 模版参数
|
||||||
* @param isSend 是否发送成功
|
* @param isSend 是否发送成功
|
||||||
|
* @return 日志编号
|
||||||
*/
|
*/
|
||||||
Long createMailLog(Long userId,Integer userType,String to,MailAccountDO mailAccountDO, MailTemplateDO template , String templateContent, Map<String, Object> templateParams, Boolean isSend);
|
Long createMailLog(Long userId,Integer userType, String toMail,
|
||||||
|
MailAccountDO account, MailTemplateDO template ,
|
||||||
|
String templateContent, Map<String, Object> templateParams, Boolean isSend);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 更新邮件发送结果
|
* 更新邮件发送结果
|
||||||
*
|
*
|
||||||
* @param logId 发送日志Id
|
* @param logId 日志编号
|
||||||
* @param result 发送结果 默认返回messageId
|
* @param messageId 发送后的消息编号
|
||||||
|
* @param exception 发送异常
|
||||||
*/
|
*/
|
||||||
void updateMailSendResult(Long logId, String result);
|
void updateMailSendResult(Long logId, String messageId, Exception exception);
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新邮件发送结果
|
|
||||||
*
|
|
||||||
* @param logId 发送日志Id
|
|
||||||
* @param exception 发送结果
|
|
||||||
*/
|
|
||||||
void updateFailMailSendResult(Long logId, String exception);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package cn.iocoder.yudao.module.system.service.mail;
|
package cn.iocoder.yudao.module.system.service.mail;
|
||||||
|
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
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.controller.admin.mail.vo.log.MailLogPageReqVO;
|
||||||
import cn.iocoder.yudao.module.system.dal.dataobject.mail.MailAccountDO;
|
import cn.iocoder.yudao.module.system.dal.dataobject.mail.MailAccountDO;
|
||||||
import cn.iocoder.yudao.module.system.dal.dataobject.mail.MailLogDO;
|
import cn.iocoder.yudao.module.system.dal.dataobject.mail.MailLogDO;
|
||||||
@ -13,10 +12,11 @@ import org.springframework.validation.annotation.Validated;
|
|||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
|
import static cn.hutool.core.exceptions.ExceptionUtil.getRootCauseMessage;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 邮件日志 Service 实现类
|
* 邮件日志 Service 实现类
|
||||||
*
|
*
|
||||||
@ -35,11 +35,6 @@ public class MailLogServiceImpl implements MailLogService {
|
|||||||
return mailLogMapper.selectPage(pageVO);
|
return mailLogMapper.selectPage(pageVO);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<MailLogDO> getMailLogList(MailLogExportReqVO exportReqVO) {
|
|
||||||
return mailLogMapper.selectList(exportReqVO);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Long createMailLog(Long userId, Integer userType, String toMail,
|
public Long createMailLog(Long userId, Integer userType, String toMail,
|
||||||
MailAccountDO account, MailTemplateDO template,
|
MailAccountDO account, MailTemplateDO template,
|
||||||
@ -61,20 +56,18 @@ public class MailLogServiceImpl implements MailLogService {
|
|||||||
return logDO.getId();
|
return logDO.getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO @wangjingyi:还是加几个字段哈,日志上。sendStatus,成功、失败;messageId 消息标号。sendException 记录发送的异常。这样界面才好筛选邮件的发送结果。DONE
|
|
||||||
@Override
|
@Override
|
||||||
public void updateMailSendResult(Long logId, String result) {
|
public void updateMailSendResult(Long logId, String messageId, Exception exception) {
|
||||||
MailLogDO.MailLogDOBuilder logDOBuilder = MailLogDO.builder();
|
// 1. 成功
|
||||||
logDOBuilder.id(logId).sendTime(new Date()).sendResult(result).sendMessageId(result).sendStatus(MailSendStatusEnum.SUCCESS.getStatus());
|
if (exception == null) {
|
||||||
MailLogDO mailLogDO = logDOBuilder.build();
|
mailLogMapper.updateById(new MailLogDO().setId(logId).setSendTime(new Date())
|
||||||
mailLogMapper.updateById(mailLogDO);
|
.setSendStatus(MailSendStatusEnum.SUCCESS.getStatus()).setSendMessageId(messageId));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// 2. 失败
|
||||||
|
mailLogMapper.updateById(new MailLogDO().setId(logId).setSendTime(new Date())
|
||||||
|
.setSendStatus(MailSendStatusEnum.FAILURE.getStatus()).setSendException(getRootCauseMessage(exception)));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void updateFailMailSendResult(Long logId, String exception) {
|
|
||||||
MailLogDO.MailLogDOBuilder logDOBuilder = MailLogDO.builder();
|
|
||||||
logDOBuilder.id(logId).sendTime(new Date()).sendResult(exception).sendStatus(MailSendStatusEnum.FAILURE.getStatus());
|
|
||||||
MailLogDO mailLogDO = logDOBuilder.build();
|
|
||||||
mailLogMapper.updateById(mailLogDO);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -9,14 +9,9 @@ import cn.iocoder.yudao.framework.common.enums.UserTypeEnum;
|
|||||||
import cn.iocoder.yudao.module.system.convert.mail.MailAccountConvert;
|
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.dataobject.mail.MailAccountDO;
|
||||||
import cn.iocoder.yudao.module.system.dal.dataobject.mail.MailTemplateDO;
|
import cn.iocoder.yudao.module.system.dal.dataobject.mail.MailTemplateDO;
|
||||||
import cn.iocoder.yudao.module.system.dal.dataobject.sms.SmsChannelDO;
|
|
||||||
import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO;
|
import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO;
|
||||||
import cn.iocoder.yudao.module.system.dal.mysql.mail.MailAccountMapper;
|
|
||||||
import cn.iocoder.yudao.module.system.mq.message.mail.MailSendMessage;
|
import cn.iocoder.yudao.module.system.mq.message.mail.MailSendMessage;
|
||||||
import cn.iocoder.yudao.module.system.mq.producer.mail.MailProducer;
|
import cn.iocoder.yudao.module.system.mq.producer.mail.MailProducer;
|
||||||
import cn.iocoder.yudao.module.system.service.mail.MailLogService;
|
|
||||||
import cn.iocoder.yudao.module.system.service.mail.MailSendService;
|
|
||||||
import cn.iocoder.yudao.module.system.service.mail.MailTemplateService;
|
|
||||||
import cn.iocoder.yudao.module.system.service.member.MemberService;
|
import cn.iocoder.yudao.module.system.service.member.MemberService;
|
||||||
import cn.iocoder.yudao.module.system.service.user.AdminUserService;
|
import cn.iocoder.yudao.module.system.service.user.AdminUserService;
|
||||||
import com.google.common.annotations.VisibleForTesting;
|
import com.google.common.annotations.VisibleForTesting;
|
||||||
@ -111,15 +106,18 @@ public class MailSendServiceImpl implements MailSendService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void doSendMail(MailSendMessage message) {
|
public void doSendMail(MailSendMessage message) {
|
||||||
// 装载账号信息
|
// 1. 创建发送账号
|
||||||
MailAccount mailAccount = MailAccountConvert.INSTANCE.convertAccount(message);
|
MailAccountDO account = checkMailAccountValid(message.getAccountId());
|
||||||
// 发送邮件
|
MailAccount mailAccount = MailAccountConvert.INSTANCE.convert(account, message.getNickname());
|
||||||
|
// 2. 发送邮件
|
||||||
try {
|
try {
|
||||||
String messageId = MailUtil.send(mailAccount, message.getMail(),
|
String messageId = MailUtil.send(mailAccount, message.getMail(),
|
||||||
message.getTitle(), message.getContent(),true);
|
message.getTitle(), message.getContent(),true);
|
||||||
mailLogService.updateMailSendResult(message.getLogId() , messageId);
|
// 3. 更新结果(成功)
|
||||||
} catch (Exception e){
|
mailLogService.updateMailSendResult(message.getLogId(), messageId, null);
|
||||||
mailLogService.updateFailMailSendResult(message.getLogId() , e.getMessage());
|
} catch (Exception e) {
|
||||||
|
// 3. 更新结果(异常)
|
||||||
|
mailLogService.updateMailSendResult(message.getLogId(), null, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -170,4 +168,5 @@ public class MailSendServiceImpl implements MailSendService {
|
|||||||
return new KeyValue<>(key, value);
|
return new KeyValue<>(key, value);
|
||||||
}).collect(Collectors.toList());
|
}).collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
18
yudao-ui-admin/src/api/system/mail/log.js
Executable file
18
yudao-ui-admin/src/api/system/mail/log.js
Executable file
@ -0,0 +1,18 @@
|
|||||||
|
import request from '@/utils/request'
|
||||||
|
|
||||||
|
// 获得邮件日志
|
||||||
|
export function getMailLog(id) {
|
||||||
|
return request({
|
||||||
|
url: '/system/mail-log/get?id=' + id,
|
||||||
|
method: 'get'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获得邮件日志分页
|
||||||
|
export function getMailLogPage(query) {
|
||||||
|
return request({
|
||||||
|
url: '/system/mail-log/page',
|
||||||
|
method: 'get',
|
||||||
|
params: query
|
||||||
|
})
|
||||||
|
}
|
@ -25,6 +25,7 @@ export const DICT_TYPE = {
|
|||||||
SYSTEM_SMS_RECEIVE_STATUS: 'system_sms_receive_status',
|
SYSTEM_SMS_RECEIVE_STATUS: 'system_sms_receive_status',
|
||||||
SYSTEM_ERROR_CODE_TYPE: 'system_error_code_type',
|
SYSTEM_ERROR_CODE_TYPE: 'system_error_code_type',
|
||||||
SYSTEM_OAUTH2_GRANT_TYPE: 'system_oauth2_grant_type',
|
SYSTEM_OAUTH2_GRANT_TYPE: 'system_oauth2_grant_type',
|
||||||
|
SYSTEM_MAIL_SEND_STATUS: 'system_mail_send_status',
|
||||||
|
|
||||||
// ========== INFRA 模块 ==========
|
// ========== INFRA 模块 ==========
|
||||||
INFRA_BOOLEAN_STRING: 'infra_boolean_string',
|
INFRA_BOOLEAN_STRING: 'infra_boolean_string',
|
||||||
|
225
yudao-ui-admin/src/views/system/mail/log/index.vue
Executable file
225
yudao-ui-admin/src/views/system/mail/log/index.vue
Executable file
@ -0,0 +1,225 @@
|
|||||||
|
<template>
|
||||||
|
<div class="app-container">
|
||||||
|
|
||||||
|
<!-- 搜索工作栏 -->
|
||||||
|
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
|
||||||
|
<el-form-item label="接收邮箱" prop="toMail">
|
||||||
|
<el-input v-model="queryParams.toMail" placeholder="请输入接收邮箱" clearable @keyup.enter.native="handleQuery"/>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="邮箱账号" prop="accountId">
|
||||||
|
<el-select v-model="queryParams.accountId" placeholder="请输入邮箱账号" clearable>
|
||||||
|
<el-option v-for="account in accountOptions" :key="account.id" :value="account.id" :label="account.mail" />
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="模板编号" prop="templateId">
|
||||||
|
<el-input v-model="queryParams.templateId" placeholder="请输入模板编号" clearable @keyup.enter.native="handleQuery"/>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="发送状态" prop="sendStatus">
|
||||||
|
<el-select v-model="queryParams.sendStatus" placeholder="请选择发送状态" clearable size="small">
|
||||||
|
<el-option v-for="dict in this.getDictDatas(DICT_TYPE.SYSTEM_MAIL_SEND_STATUS)"
|
||||||
|
:key="dict.value" :label="dict.label" :value="dict.value"/>
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="发送时间" prop="sendTime">
|
||||||
|
<el-date-picker v-model="queryParams.sendTime" style="width: 240px" value-format="yyyy-MM-dd HH:mm:ss" type="daterange"
|
||||||
|
range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期" :default-time="['00:00:00', '23:59:59']" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="用户编号" prop="userId">
|
||||||
|
<el-input v-model="queryParams.userId" placeholder="请输入用户编号" clearable @keyup.enter.native="handleQuery"/>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="用户类型" prop="userType">
|
||||||
|
<el-select v-model="queryParams.userType" placeholder="请选择用户类型" clearable>
|
||||||
|
<el-option v-for="dict in this.getDictDatas(DICT_TYPE.USER_TYPE)"
|
||||||
|
:key="dict.value" :label="dict.label" :value="dict.value"/>
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item>
|
||||||
|
<el-button type="primary" icon="el-icon-search" @click="handleQuery">搜索</el-button>
|
||||||
|
<el-button icon="el-icon-refresh" @click="resetQuery">重置</el-button>
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
|
||||||
|
<!-- 操作工具栏 -->
|
||||||
|
<el-row :gutter="10" class="mb8">
|
||||||
|
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
||||||
|
</el-row>
|
||||||
|
|
||||||
|
<!-- 列表 -->
|
||||||
|
<el-table v-loading="loading" :data="list">
|
||||||
|
<el-table-column label="编号" align="center" prop="id" />
|
||||||
|
<el-table-column label="发送时间" align="center" prop="sendTime" width="180">
|
||||||
|
<template v-slot="scope">
|
||||||
|
<span>{{ parseTime(scope.row.sendTime) }}</span>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="接收邮箱" align="center" prop="toMail" width="200">
|
||||||
|
<template v-slot="scope">
|
||||||
|
<div>{{ scope.row.toMail }}</div>
|
||||||
|
<div v-if="scope.row.userType && scope.row.userId">
|
||||||
|
<dict-tag :type="DICT_TYPE.USER_TYPE" :value="scope.row.userType"/>{{ '(' + scope.row.userId + ')' }}
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="邮件标题" align="center" prop="templateTitle" />
|
||||||
|
<el-table-column label="发送状态" align="center" prop="sendStatus">
|
||||||
|
<template v-slot="scope">
|
||||||
|
<dict-tag :type="DICT_TYPE.SYSTEM_MAIL_SEND_STATUS" :value="scope.row.sendStatus" />
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="邮箱账号" align="center" prop="fromMail" />
|
||||||
|
<el-table-column label="模板编号" align="center" prop="templateId" />
|
||||||
|
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
||||||
|
<template v-slot="scope">
|
||||||
|
<el-button size="mini" type="text" icon="el-icon-view" @click="handleView(scope.row)"
|
||||||
|
v-hasPermi="['system:mail-log:query']">详细</el-button>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
</el-table>
|
||||||
|
<!-- 分页组件 -->
|
||||||
|
<pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNo" :limit.sync="queryParams.pageSize"
|
||||||
|
@pagination="getList"/>
|
||||||
|
|
||||||
|
<!-- 邮件日志详细-->
|
||||||
|
<el-dialog :title="title" :visible.sync="open" width="700px" v-dialogDrag append-to-body>
|
||||||
|
<el-form ref="form" :model="form" label-width="160px">
|
||||||
|
<el-row>
|
||||||
|
<el-col :span="24">
|
||||||
|
<el-form-item label="日志主键:">{{ form.id }}</el-form-item>
|
||||||
|
<el-form-item label="用户编号:">{{ form.userId }}</el-form-item>
|
||||||
|
<el-form-item label="用户类型:">
|
||||||
|
<dict-tag :type="DICT_TYPE.USER_TYPE" :value="form.userType"/>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="接收邮箱地址:">{{ form.toMail }}</el-form-item>
|
||||||
|
<el-form-item label="邮箱账号编号:">{{ form.accountId }}</el-form-item>
|
||||||
|
<el-form-item label="发送邮箱地址:">{{ form.fromMail }}</el-form-item>
|
||||||
|
<el-form-item label="模板编号:">{{ form.templateId }}</el-form-item>
|
||||||
|
<el-form-item label="模板编码:">{{ form.templateCode }}</el-form-item>
|
||||||
|
<el-form-item label="模版发送人名称:">{{ form.templateNickname }}</el-form-item>
|
||||||
|
<el-form-item label="邮件标题:">{{ form.templateTitle }}</el-form-item>
|
||||||
|
<el-form-item label="邮件内容:">
|
||||||
|
<editor v-model="form.templateContent" :min-height="192" read-only />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="邮件参数:">{{ form.templateParams }}</el-form-item>
|
||||||
|
<el-form-item label="发送状态:">
|
||||||
|
<dict-tag :type="DICT_TYPE.SYSTEM_MAIL_SEND_STATUS" :value="form.sendStatus" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="发送时间:">{{ parseTime(form.sendTime) }}</el-form-item>
|
||||||
|
<el-form-item label="发送返回的消息编号:">{{ form.sendMessageId }}</el-form-item>
|
||||||
|
<el-form-item label="发送异常:">{{ form.sendException }}</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
</el-form>
|
||||||
|
<div slot="footer" class="dialog-footer">
|
||||||
|
<el-button @click="open = false">关 闭</el-button>
|
||||||
|
</div>
|
||||||
|
</el-dialog>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import { getMailLog, getMailLogPage } from "@/api/system/mail/log";
|
||||||
|
import Editor from '@/components/Editor';
|
||||||
|
import { getSimpleMailAccountList } from "@/api/system/mail/account";
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: "MailLog",
|
||||||
|
components: {
|
||||||
|
Editor,
|
||||||
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
// 遮罩层
|
||||||
|
loading: true,
|
||||||
|
// 导出遮罩层
|
||||||
|
exportLoading: false,
|
||||||
|
// 显示搜索条件
|
||||||
|
showSearch: true,
|
||||||
|
// 总条数
|
||||||
|
total: 0,
|
||||||
|
// 邮件日志列表
|
||||||
|
list: [],
|
||||||
|
// 弹出层标题
|
||||||
|
title: "",
|
||||||
|
// 是否显示弹出层
|
||||||
|
open: false,
|
||||||
|
// 查询参数
|
||||||
|
queryParams: {
|
||||||
|
pageNo: 1,
|
||||||
|
pageSize: 10,
|
||||||
|
userId: null,
|
||||||
|
userType: null,
|
||||||
|
toMail: null,
|
||||||
|
accountId: null,
|
||||||
|
templateId: null,
|
||||||
|
sendStatus: null,
|
||||||
|
sendTime: [],
|
||||||
|
},
|
||||||
|
// 表单参数
|
||||||
|
form: {},
|
||||||
|
// 邮箱账号
|
||||||
|
accountOptions: []
|
||||||
|
};
|
||||||
|
},
|
||||||
|
created() {
|
||||||
|
this.getList();
|
||||||
|
// 获得邮箱账号列表
|
||||||
|
getSimpleMailAccountList().then(response => {
|
||||||
|
this.accountOptions = response.data
|
||||||
|
})
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
/** 查询列表 */
|
||||||
|
getList() {
|
||||||
|
this.loading = true;
|
||||||
|
// 执行查询
|
||||||
|
getMailLogPage(this.queryParams).then(response => {
|
||||||
|
this.list = response.data.list;
|
||||||
|
this.total = response.data.total;
|
||||||
|
this.loading = false;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
/** 取消按钮 */
|
||||||
|
cancel() {
|
||||||
|
this.open = false;
|
||||||
|
this.reset();
|
||||||
|
},
|
||||||
|
/** 表单重置 */
|
||||||
|
reset() {
|
||||||
|
this.form = {
|
||||||
|
id: undefined,
|
||||||
|
userId: undefined,
|
||||||
|
userType: undefined,
|
||||||
|
toMail: undefined,
|
||||||
|
accountId: undefined,
|
||||||
|
fromMail: undefined,
|
||||||
|
templateId: undefined,
|
||||||
|
templateCode: undefined,
|
||||||
|
templateNickname: undefined,
|
||||||
|
templateTitle: undefined,
|
||||||
|
templateContent: undefined,
|
||||||
|
templateParams: undefined,
|
||||||
|
sendStatus: undefined,
|
||||||
|
sendTime: undefined,
|
||||||
|
sendMessageId: undefined,
|
||||||
|
sendException: undefined,
|
||||||
|
};
|
||||||
|
this.resetForm("form");
|
||||||
|
},
|
||||||
|
/** 搜索按钮操作 */
|
||||||
|
handleQuery() {
|
||||||
|
this.queryParams.pageNo = 1;
|
||||||
|
this.getList();
|
||||||
|
},
|
||||||
|
/** 重置按钮操作 */
|
||||||
|
resetQuery() {
|
||||||
|
this.resetForm("queryForm");
|
||||||
|
this.handleQuery();
|
||||||
|
},
|
||||||
|
/** 详细按钮操作 */
|
||||||
|
handleView(row) {
|
||||||
|
this.open = true;
|
||||||
|
this.form = row;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
</script>
|
@ -44,7 +44,7 @@
|
|||||||
<el-table-column label="模板编码" align="center" prop="code" />
|
<el-table-column label="模板编码" align="center" prop="code" />
|
||||||
<el-table-column label="模板名称" align="center" prop="name" />
|
<el-table-column label="模板名称" align="center" prop="name" />
|
||||||
<el-table-column label="模板标题" align="center" prop="title" />
|
<el-table-column label="模板标题" align="center" prop="title" />
|
||||||
<el-table-column label="邮箱账号" align="center" prop="accountId">
|
<el-table-column label="邮箱账号" align="center" prop="accountId" width="200">
|
||||||
<template v-slot="scope">
|
<template v-slot="scope">
|
||||||
{{ accountOptions.find(account => account.id === scope.row.accountId)?.mail }}
|
{{ accountOptions.find(account => account.id === scope.row.accountId)?.mail }}
|
||||||
</template>
|
</template>
|
||||||
|
@ -94,7 +94,7 @@
|
|||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
||||||
<template v-slot="scope">
|
<template v-slot="scope">
|
||||||
<el-button size="mini" type="text" icon="el-icon-view" @click="handleView(scope.row,scope.index)"
|
<el-button size="mini" type="text" icon="el-icon-view" @click="handleView(scope.row)"
|
||||||
v-hasPermi="['system:sms-log:query']">详细</el-button>
|
v-hasPermi="['system:sms-log:query']">详细</el-button>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
|
Loading…
Reference in New Issue
Block a user