简单邮件发送功能完成
parent
932b4da710
commit
24f1f4c3e7
|
|
@ -53,6 +53,17 @@ public class SpringMailSender implements MailSender {
|
|||
//超时设置
|
||||
mailProperties.setProperty("mail.smtp.connectiontimeout", timeout + "");//与邮件服务器建立连接的超时
|
||||
mailProperties.setProperty("mail.smtp.writetimeout", timeout + "");//邮件发送时间限制
|
||||
javaMailSender.setDefaultEncoding("UTF-8");
|
||||
System.setProperty("mail.mime.splitlongparameters", "false"); //注意:不截断base64编码后的长附件名
|
||||
//设置认证信息
|
||||
setAuthInfo(javaMailSender, account, mailProperties);
|
||||
return javaMailSender;
|
||||
}
|
||||
|
||||
private void setAuthInfo(JavaMailSenderImpl executor, MailSendAccount account, Properties mailProperties) {
|
||||
if (mailProperties == null) {
|
||||
mailProperties = executor.getJavaMailProperties();
|
||||
}
|
||||
if (account.isSslFlag()) {
|
||||
//开启ssl
|
||||
System.out.println("****** enable ssl for mail send ******");
|
||||
|
|
@ -61,18 +72,14 @@ public class SpringMailSender implements MailSender {
|
|||
mailProperties.setProperty("mail.smtp.ssl.enable", "true");
|
||||
} else {
|
||||
System.out.println("****** disable ssl for mail send ******");
|
||||
javaMailSender.setPort(account.getPort());
|
||||
executor.setPort(account.getPort() == null ? 25 : account.getPort());
|
||||
}
|
||||
javaMailSender.setJavaMailProperties(mailProperties);
|
||||
javaMailSender.setHost(account.getHost());
|
||||
javaMailSender.setUsername(account.getUsername());
|
||||
javaMailSender.setPassword(account.getPassword());
|
||||
javaMailSender.setDefaultEncoding("UTF-8");
|
||||
System.setProperty("mail.mime.splitlongparameters", "false"); //注意:不截断base64编码后的长附件名
|
||||
return javaMailSender;
|
||||
executor.setJavaMailProperties(mailProperties);
|
||||
executor.setHost(account.getHost());
|
||||
executor.setUsername(account.getUsername());
|
||||
executor.setPassword(account.getPassword());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 创建邮件信息
|
||||
*
|
||||
|
|
@ -90,13 +97,13 @@ public class SpringMailSender implements MailSender {
|
|||
//创建发送MIME邮件的工具类
|
||||
MimeMessageHelper messageHelper = getMimeMessageHelper(form, mimeMessage, headInfo);
|
||||
//设置正文多媒体信息
|
||||
if (inLineMap != null) {
|
||||
if (inLineMap != null && !inLineMap.isEmpty()) {
|
||||
for (Map.Entry<String, File> inLine : inLineMap.entrySet()) {
|
||||
messageHelper.addInline(inLine.getKey(), inLine.getValue());
|
||||
}
|
||||
}
|
||||
//添加附件
|
||||
if (attachments != null) {
|
||||
if (attachments != null && !attachments.isEmpty()) {
|
||||
for (Map.Entry<String, File> entry : attachments.entrySet()) {
|
||||
String fileName = entry.getKey();
|
||||
File file = entry.getValue();
|
||||
|
|
@ -111,9 +118,8 @@ public class SpringMailSender implements MailSender {
|
|||
//发件人
|
||||
if (form.getFrom() == null || form.getFrom().isEmpty()) {
|
||||
form.setFrom(senderAccount.getUsername());
|
||||
} else {
|
||||
form.setFrom(form.getFrom());
|
||||
}
|
||||
messageHelper.setFrom(form.getFrom());
|
||||
//收件人 这里的参数可以是多个收件人,用英文分号分割
|
||||
messageHelper.setTo(headInfo.getTo().split(ADDRESS_SPLIT));
|
||||
//抄送 这里的参数可以是多个抄送人,用英文分号分割
|
||||
|
|
@ -125,6 +131,8 @@ public class SpringMailSender implements MailSender {
|
|||
//邮件正文
|
||||
if (form.getContent() != null && !form.getContent().isEmpty()) {
|
||||
messageHelper.setText(form.getContent(), form.isHtml());
|
||||
} else {
|
||||
messageHelper.setText("");
|
||||
}
|
||||
return messageHelper;
|
||||
}
|
||||
|
|
@ -160,6 +168,7 @@ public class SpringMailSender implements MailSender {
|
|||
public void resetSenderAccount(MailSendAccount senderAccount) {
|
||||
checkAccount(senderAccount);
|
||||
this.senderAccount = senderAccount;
|
||||
setAuthInfo(executor, senderAccount, null);
|
||||
}
|
||||
|
||||
private void checkAccount(MailSendAccount account) {
|
||||
|
|
|
|||
|
|
@ -4,11 +4,14 @@ import com.ruoyi.common.core.mail.MailSendAccount;
|
|||
import com.ruoyi.common.core.mail.MailSender;
|
||||
import com.ruoyi.common.core.utils.StringUtils;
|
||||
import com.ruoyi.common.security.utils.SysConfigUtils;
|
||||
import lombok.Getter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
* 邮件配置
|
||||
*
|
||||
|
|
@ -28,6 +31,12 @@ public class MailConfig {
|
|||
@Value("${spring.mail.password:#{null}}")
|
||||
private String password;
|
||||
|
||||
@Getter
|
||||
private File attachmentsSavedDir;
|
||||
|
||||
private MailSender mailSender;
|
||||
|
||||
|
||||
@Bean
|
||||
public MailSender mailSender() {
|
||||
MailSendAccount account = new MailSendAccount();
|
||||
|
|
@ -38,11 +47,27 @@ public class MailConfig {
|
|||
account.setUsername(username);
|
||||
account.setPassword(password);
|
||||
|
||||
getFromCache(account);
|
||||
mailSender = MailSender.build(account, true);
|
||||
log.info("Mail configuration has been initialized. smtpHost: [{}], smtpPort: [{}], username: [{}]", account.getHost(), account.getPort(), account.getUsername());
|
||||
|
||||
return mailSender;
|
||||
}
|
||||
|
||||
/**
|
||||
* 从缓存中获取邮件配置
|
||||
*/
|
||||
@SuppressWarnings("ResultOfMethodCallIgnored")
|
||||
private void getFromCache(MailSendAccount account) {
|
||||
if (account == null) {
|
||||
throw new IllegalArgumentException("MailSendAccount is null");
|
||||
}
|
||||
// 加载数据库中的邮件配置(会缓存到redis中,并覆盖前面的配置)
|
||||
String hostCache = SysConfigUtils.getConfigCache("sys.mail.smtpHost");
|
||||
String portCache = SysConfigUtils.getConfigCache("sys.mail.smtpPort");
|
||||
String usernameCache = SysConfigUtils.getConfigCache("sys.mail.username");
|
||||
String passwordCache = SysConfigUtils.getConfigCache("sys.mail.password");
|
||||
String attachmentsSavedPath = SysConfigUtils.getConfigCache("sys.mail.attachmentsSavedPath");
|
||||
if (StringUtils.isNotBlank(hostCache) && StringUtils.isNotBlank(portCache)) {
|
||||
account.setHost(hostCache);
|
||||
account.setPort(Integer.parseInt(portCache));
|
||||
|
|
@ -52,13 +77,27 @@ public class MailConfig {
|
|||
if (StringUtils.isNotBlank(passwordCache)) {
|
||||
account.setPassword(passwordCache);
|
||||
}
|
||||
if (StringUtils.isNotBlank(attachmentsSavedPath)) {
|
||||
attachmentsSavedDir = new File(attachmentsSavedPath);
|
||||
if (!attachmentsSavedDir.exists()) {
|
||||
log.info("Mail attachments saved directory does not exist. Create a new one: [{}]", attachmentsSavedDir.getAbsolutePath());
|
||||
attachmentsSavedDir.mkdirs();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
log.warn("Mail configuration from database table 'sys_config' is empty. Use the configuration from application.yaml instead.");
|
||||
}
|
||||
|
||||
account.setSslFlag(account.getPassword() != null && !account.getPassword().isEmpty());
|
||||
log.info("Mail configuration has been initialized. smtpHost: [{}], smtpPort: [{}], username: [{}]", account.getHost(), account.getPort(), account.getUsername());
|
||||
return MailSender.build(account, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 刷新缓存里的邮件配置
|
||||
*/
|
||||
public void refreshCache() {
|
||||
MailSendAccount account = mailSender.getSenderAccount();
|
||||
getFromCache(account);
|
||||
mailSender.resetSenderAccount(account);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
package com.ruoyi.system.controller;
|
||||
|
||||
import com.ruoyi.common.core.mail.MailMessage;
|
||||
import com.ruoyi.common.core.mail.MailSendResult;
|
||||
import com.ruoyi.common.core.utils.poi.ExcelUtil;
|
||||
import com.ruoyi.common.core.web.controller.BaseController;
|
||||
|
|
@ -10,6 +9,7 @@ import com.ruoyi.common.log.annotation.Log;
|
|||
import com.ruoyi.common.log.enums.BusinessType;
|
||||
import com.ruoyi.common.security.annotation.RequiresPermissions;
|
||||
import com.ruoyi.system.domain.SysMailLog;
|
||||
import com.ruoyi.system.domain.vo.MailVo;
|
||||
import com.ruoyi.system.service.ISysMailLogService;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
|
@ -61,21 +61,6 @@ public class SysMailLogController extends BaseController {
|
|||
return success(sysMailLogService.selectSysMailLogByMailLogId(mailLogId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 临时邮件发送
|
||||
*/
|
||||
@RequiresPermissions("system:mailLog:send")
|
||||
@Log(title = "临时邮件发送", businessType = BusinessType.OTHER)
|
||||
@PostMapping("/sendTemporality")
|
||||
public AjaxResult sendTemporality(@RequestBody MailMessage message) {
|
||||
MailSendResult result = sysMailLogService.sendTempMail(message);
|
||||
if (result.isSuccess()) {
|
||||
return success();
|
||||
} else {
|
||||
return error(result.getErrMsg());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除邮件发送日志
|
||||
*/
|
||||
|
|
@ -85,4 +70,28 @@ public class SysMailLogController extends BaseController {
|
|||
public AjaxResult remove(@PathVariable Long[] mailLogIds) {
|
||||
return toAjax(sysMailLogService.deleteSysMailLogByMailLogIds(mailLogIds));
|
||||
}
|
||||
|
||||
/**
|
||||
* 临时邮件发送
|
||||
*/
|
||||
@RequiresPermissions("system:mailLog:send")
|
||||
@Log(title = "临时邮件发送", businessType = BusinessType.OTHER)
|
||||
@PostMapping("/sendTemporality")
|
||||
public AjaxResult sendTemporality(MailVo mailVo) {
|
||||
MailSendResult result = sysMailLogService.sendSimpleMail(mailVo);
|
||||
if (result.isSuccess()) {
|
||||
return success();
|
||||
} else {
|
||||
return error(result.getErrMsg());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取邮件发送者信息
|
||||
*/
|
||||
@RequiresPermissions("system:mailLog:query")
|
||||
@GetMapping(value = "/getMailSenderInfo")
|
||||
public AjaxResult getMailSenderInfo() {
|
||||
return success(sysMailLogService.getMailSenderInfo());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,9 +1,10 @@
|
|||
package com.ruoyi.system.domain;
|
||||
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
import com.ruoyi.common.core.annotation.Excel;
|
||||
import com.ruoyi.common.core.web.domain.BaseEntity;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
|
||||
import java.io.Serial;
|
||||
|
||||
|
|
@ -13,10 +14,22 @@ import java.io.Serial;
|
|||
* @author ryas
|
||||
* created on 2024-03-01
|
||||
*/
|
||||
@ToString(callSuper = true)
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
public class SysMailLog extends BaseEntity {
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
//==================== ↓↓↓↓↓↓ 非表字段 ↓↓↓↓↓↓ ====================
|
||||
|
||||
/**
|
||||
* 创建者用户名
|
||||
*/
|
||||
private String createByName;
|
||||
|
||||
//==================== ↓↓↓↓↓↓ 表字段 ↓↓↓↓↓↓ ====================
|
||||
|
||||
/**
|
||||
* 日志主键
|
||||
*/
|
||||
|
|
@ -70,93 +83,4 @@ public class SysMailLog extends BaseEntity {
|
|||
@Excel(name = "消耗时间(ms)")
|
||||
private Long costTime;
|
||||
|
||||
public void setMailLogId(Long mailLogId) {
|
||||
this.mailLogId = mailLogId;
|
||||
}
|
||||
|
||||
public Long getMailLogId() {
|
||||
return mailLogId;
|
||||
}
|
||||
|
||||
public void setStatus(Long status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public Long getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setBusinessType(String businessType) {
|
||||
this.businessType = businessType;
|
||||
}
|
||||
|
||||
public String getBusinessType() {
|
||||
return businessType;
|
||||
}
|
||||
|
||||
public void setFrom(String from) {
|
||||
this.from = from;
|
||||
}
|
||||
|
||||
public String getFrom() {
|
||||
return from;
|
||||
}
|
||||
|
||||
public void setTo(String to) {
|
||||
this.to = to;
|
||||
}
|
||||
|
||||
public String getTo() {
|
||||
return to;
|
||||
}
|
||||
|
||||
public void setCc(String cc) {
|
||||
this.cc = cc;
|
||||
}
|
||||
|
||||
public String getCc() {
|
||||
return cc;
|
||||
}
|
||||
|
||||
public void setSubject(String subject) {
|
||||
this.subject = subject;
|
||||
}
|
||||
|
||||
public String getSubject() {
|
||||
return subject;
|
||||
}
|
||||
|
||||
public void setMsg(String msg) {
|
||||
this.msg = msg;
|
||||
}
|
||||
|
||||
public String getMsg() {
|
||||
return msg;
|
||||
}
|
||||
|
||||
public void setCostTime(Long costTime) {
|
||||
this.costTime = costTime;
|
||||
}
|
||||
|
||||
public Long getCostTime() {
|
||||
return costTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
|
||||
.append("mailLogId", getMailLogId())
|
||||
.append("status", getStatus())
|
||||
.append("businessType", getBusinessType())
|
||||
.append("from", getFrom())
|
||||
.append("to", getTo())
|
||||
.append("cc", getCc())
|
||||
.append("subject", getSubject())
|
||||
.append("msg", getMsg())
|
||||
.append("createTime", getCreateTime())
|
||||
.append("createBy", getCreateBy())
|
||||
.append("costTime", getCostTime())
|
||||
.append("remark", getRemark())
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,48 @@
|
|||
package com.ruoyi.system.domain.vo;
|
||||
|
||||
import lombok.Data;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
/**
|
||||
* @author Alan Scipio
|
||||
* created on 2024/3/4
|
||||
*/
|
||||
@Data
|
||||
public class MailVo {
|
||||
|
||||
/**
|
||||
* 业务类型
|
||||
*/
|
||||
private String businessType;
|
||||
|
||||
/**
|
||||
* 发送人
|
||||
*/
|
||||
private String from;
|
||||
|
||||
/**
|
||||
* 接收人
|
||||
*/
|
||||
private String to;
|
||||
|
||||
/**
|
||||
* 抄送人
|
||||
*/
|
||||
private String cc;
|
||||
|
||||
/**
|
||||
* 邮件主题
|
||||
*/
|
||||
private String subject;
|
||||
|
||||
/**
|
||||
* 邮件内容
|
||||
*/
|
||||
private String content;
|
||||
|
||||
/**
|
||||
* 附件
|
||||
*/
|
||||
private MultipartFile[] attachments;
|
||||
|
||||
}
|
||||
|
|
@ -1,8 +1,9 @@
|
|||
package com.ruoyi.system.service;
|
||||
|
||||
import com.ruoyi.common.core.mail.MailMessage;
|
||||
import com.ruoyi.common.core.mail.MailSendAccount;
|
||||
import com.ruoyi.common.core.mail.MailSendResult;
|
||||
import com.ruoyi.system.domain.SysMailLog;
|
||||
import com.ruoyi.system.domain.vo.MailVo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
|
@ -62,10 +63,15 @@ public interface ISysMailLogService {
|
|||
int deleteSysMailLogByMailLogId(Long mailLogId);
|
||||
|
||||
/**
|
||||
* 发送临时邮件
|
||||
* 发送邮件 - 简易版
|
||||
*
|
||||
* @param message 邮件内容
|
||||
* @param mailVo 邮件内容
|
||||
* @return 结果
|
||||
*/
|
||||
MailSendResult sendTempMail(MailMessage message);
|
||||
MailSendResult sendSimpleMail(MailVo mailVo);
|
||||
|
||||
/**
|
||||
* 获取邮件发送账户信息
|
||||
*/
|
||||
MailSendAccount getMailSenderInfo();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import com.ruoyi.common.core.exception.ServiceException;
|
|||
import com.ruoyi.common.core.text.Convert;
|
||||
import com.ruoyi.common.core.utils.StringUtils;
|
||||
import com.ruoyi.common.redis.service.RedisService;
|
||||
import com.ruoyi.system.config.MailConfig;
|
||||
import com.ruoyi.system.domain.SysConfig;
|
||||
import com.ruoyi.system.mapper.SysConfigMapper;
|
||||
import com.ruoyi.system.service.ISysConfigService;
|
||||
|
|
@ -29,6 +30,9 @@ public class SysConfigServiceImpl implements ISysConfigService {
|
|||
@Resource
|
||||
private RedisService redisService;
|
||||
|
||||
@Resource
|
||||
private MailConfig mailConfig;
|
||||
|
||||
/**
|
||||
* 项目启动时,初始化参数到缓存
|
||||
*/
|
||||
|
|
@ -167,6 +171,7 @@ public class SysConfigServiceImpl implements ISysConfigService {
|
|||
public void resetConfigCache() {
|
||||
clearConfigCache();
|
||||
loadingConfigCache();
|
||||
mailConfig.refreshCache();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -1,17 +1,29 @@
|
|||
package com.ruoyi.system.service.impl;
|
||||
|
||||
import com.ruoyi.common.core.mail.MailMessage;
|
||||
import com.ruoyi.common.core.mail.MailSendAccount;
|
||||
import com.ruoyi.common.core.mail.MailSendResult;
|
||||
import com.ruoyi.common.core.mail.MailSender;
|
||||
import com.ruoyi.common.core.utils.DateUtils;
|
||||
import com.ruoyi.common.core.utils.StringUtils;
|
||||
import com.ruoyi.common.core.utils.uuid.snowflake.SnowFlakeIdGenerator;
|
||||
import com.ruoyi.system.config.MailConfig;
|
||||
import com.ruoyi.system.domain.SysMailLog;
|
||||
import com.ruoyi.system.domain.vo.MailVo;
|
||||
import com.ruoyi.system.mapper.SysMailLogMapper;
|
||||
import com.ruoyi.system.service.ISysMailLogService;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.mail.MailSendException;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.time.LocalDate;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 邮件发送日志Service业务层处理
|
||||
|
|
@ -19,6 +31,7 @@ import java.util.List;
|
|||
* @author ryas
|
||||
* created on 2024-03-01
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class SysMailLogServiceImpl implements ISysMailLogService {
|
||||
|
||||
|
|
@ -28,6 +41,9 @@ public class SysMailLogServiceImpl implements ISysMailLogService {
|
|||
@Resource
|
||||
private MailSender mailSender;
|
||||
|
||||
@Resource
|
||||
private MailConfig mailConfig;
|
||||
|
||||
/**
|
||||
* 查询邮件发送日志
|
||||
*
|
||||
|
|
@ -62,6 +78,9 @@ public class SysMailLogServiceImpl implements ISysMailLogService {
|
|||
if (sysMailLog.getMailLogId() == null) {
|
||||
sysMailLog.setMailLogId(SnowFlakeIdGenerator.nextIdLong());
|
||||
}
|
||||
if (StringUtils.isNotBlank(sysMailLog.getMsg()) && sysMailLog.getMsg().length() > 500) {
|
||||
sysMailLog.setMsg(sysMailLog.getMsg().substring(0, 500));
|
||||
}
|
||||
return sysMailLogMapper.insertSysMailLog(sysMailLog);
|
||||
}
|
||||
|
||||
|
|
@ -73,6 +92,9 @@ public class SysMailLogServiceImpl implements ISysMailLogService {
|
|||
*/
|
||||
@Override
|
||||
public int updateSysMailLog(SysMailLog sysMailLog) {
|
||||
if (StringUtils.isNotBlank(sysMailLog.getMsg()) && sysMailLog.getMsg().length() > 500) {
|
||||
sysMailLog.setMsg(sysMailLog.getMsg().substring(0, 500));
|
||||
}
|
||||
return sysMailLogMapper.updateSysMailLog(sysMailLog);
|
||||
}
|
||||
|
||||
|
|
@ -99,14 +121,146 @@ public class SysMailLogServiceImpl implements ISysMailLogService {
|
|||
}
|
||||
|
||||
/**
|
||||
* 发送临时邮件
|
||||
* 发送邮件 - 简易版
|
||||
*
|
||||
* @param message 邮件内容
|
||||
* @param mailVo 邮件内容
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public MailSendResult sendTempMail(MailMessage message) {
|
||||
//TODO 待完成
|
||||
return null;
|
||||
public MailSendResult sendSimpleMail(MailVo mailVo) {
|
||||
// 参数校验
|
||||
if (StringUtils.isBlank(mailVo.getTo())) {
|
||||
return MailSendResult.failure("收件人不能为空");
|
||||
}
|
||||
if (StringUtils.isBlank(mailVo.getSubject())) {
|
||||
return MailSendResult.failure("邮件主题不能为空");
|
||||
}
|
||||
long startTime = System.currentTimeMillis();
|
||||
// 保存附件
|
||||
List<File> attachments;
|
||||
try {
|
||||
attachments = saveAttachments(mailVo.getAttachments());
|
||||
} catch (Exception e) {
|
||||
log.error("Failed to save mail attachments", e);
|
||||
return MailSendResult.failure("Failed to save attachments! " + e);
|
||||
}
|
||||
// 发送邮件
|
||||
MailMessage mailMessage = new MailMessage()
|
||||
.setFrom(mailVo.getFrom())
|
||||
.setTo(mailVo.getTo())
|
||||
.setCc(mailVo.getCc())
|
||||
.setSubject(mailVo.getSubject())
|
||||
.setContent(mailVo.getContent())
|
||||
.addAttachments(attachments);
|
||||
MailSendResult result = mailSender.sendMail(mailMessage);
|
||||
handleMailSendError(result);
|
||||
// 记录邮件发送日志
|
||||
addMailLog(mailVo, result, startTime);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 记录邮件发送日志
|
||||
*
|
||||
* @param mailVo 邮件内容
|
||||
* @param result 发送结果
|
||||
* @param startTime 发送开始时间
|
||||
*/
|
||||
private void addMailLog(MailVo mailVo, MailSendResult result, Long startTime) {
|
||||
SysMailLog mailLog = new SysMailLog();
|
||||
mailLog.setBusinessType(mailVo.getBusinessType());
|
||||
mailLog.setFrom(mailVo.getFrom());
|
||||
mailLog.setTo(mailVo.getTo());
|
||||
mailLog.setCc(mailVo.getCc());
|
||||
mailLog.setSubject(mailVo.getSubject());
|
||||
mailLog.setCostTime(System.currentTimeMillis() - startTime);
|
||||
if (result.isSuccess()) {
|
||||
mailLog.setStatus(1L);
|
||||
mailLog.setMsg("Send successfully");
|
||||
} else {
|
||||
mailLog.setStatus(2L);
|
||||
mailLog.setMsg(result.getErrMsg());
|
||||
}
|
||||
int affectedRows = insertSysMailLog(mailLog);
|
||||
if (affectedRows == 0) {
|
||||
log.error("Failed to record mail log: {}", mailLog);
|
||||
} else {
|
||||
log.info("Mail send successfully, mailLogId: {}", mailLog.getMailLogId());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存附件
|
||||
* <p>
|
||||
* 路径:配置的根路径+年份+月份+文件名,同名文件会覆盖
|
||||
*/
|
||||
@SuppressWarnings("ResultOfMethodCallIgnored")
|
||||
private List<File> saveAttachments(MultipartFile[] attachments) throws IOException {
|
||||
List<File> files = new ArrayList<>();
|
||||
if (attachments != null) {
|
||||
File rootDir = mailConfig.getAttachmentsSavedDir();
|
||||
LocalDate nowDate = LocalDate.now();
|
||||
File savedDir = new File(rootDir, nowDate.getYear() + File.separator + nowDate.getMonthValue());
|
||||
for (MultipartFile attachment : attachments) {
|
||||
try {
|
||||
File file = new File(savedDir, Objects.requireNonNull(attachment.getOriginalFilename()));
|
||||
if (!savedDir.exists()) {
|
||||
savedDir.mkdirs();
|
||||
}
|
||||
if (file.exists()) {
|
||||
// 删除已存在的同名附件
|
||||
log.warn("Mail attachment file already exists, delete it: [{}]", file.getAbsolutePath());
|
||||
file.delete();
|
||||
}
|
||||
attachment.transferTo(file);
|
||||
log.info("Mail attachment saved to server locally: [{}]", file.getAbsolutePath());
|
||||
files.add(file);
|
||||
} catch (IOException e) {
|
||||
// 删除已保存的附件
|
||||
for (File f : files) {
|
||||
f.delete();
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
}
|
||||
return files;
|
||||
}
|
||||
|
||||
/**
|
||||
* 进一步处理邮件发送异常
|
||||
*/
|
||||
private void handleMailSendError(MailSendResult result) {
|
||||
Throwable e = result.getErrObj();
|
||||
if (e == null) {
|
||||
return;
|
||||
}
|
||||
log.error("Failed to send mail", e);
|
||||
String msg = e.getMessage();
|
||||
if (e instanceof MailSendException) {
|
||||
if (msg != null && msg.toLowerCase().startsWith("mail server connection failed")) {
|
||||
result.setErrMsg("邮件服务器连接失败! 请检查邮件服务器地址和端口是否正确");
|
||||
} else if (msg != null && msg.toLowerCase().startsWith("mail server authentication failed")) {
|
||||
result.setErrMsg("邮件服务器认证失败! 请检查配置的用户名和密码是否正确");
|
||||
} else {
|
||||
result.setErrMsg("邮件发送失败: " + msg);
|
||||
}
|
||||
} else {
|
||||
result.setErrMsg("邮件发送失败,未知异常: " + msg);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取邮件发送账户信息
|
||||
*/
|
||||
@Override
|
||||
public MailSendAccount getMailSenderInfo() {
|
||||
MailSendAccount result = new MailSendAccount();
|
||||
MailSendAccount senderAccount = mailSender.getSenderAccount();
|
||||
result.setHost(senderAccount.getHost());
|
||||
result.setPort(senderAccount.getPort());
|
||||
result.setUsername(senderAccount.getUsername());
|
||||
result.setSslFlag(senderAccount.isSslFlag());
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@
|
|||
<result property="msg" column="msg"/>
|
||||
<result property="createTime" column="create_time"/>
|
||||
<result property="createBy" column="create_by"/>
|
||||
<result property="createByName" column="create_by_name"/>
|
||||
<result property="costTime" column="cost_time"/>
|
||||
<result property="remark" column="remark"/>
|
||||
</resultMap>
|
||||
|
|
@ -36,13 +37,28 @@
|
|||
</sql>
|
||||
|
||||
<select id="selectSysMailLogList" parameterType="com.ruoyi.system.domain.SysMailLog" resultMap="SysMailLogResult">
|
||||
<include refid="selectSysMailLogVo"/>
|
||||
select
|
||||
t.mail_log_id,
|
||||
t.status,
|
||||
t.business_type,
|
||||
t.from,
|
||||
t.to,
|
||||
t.cc,
|
||||
t.subject,
|
||||
t.msg,
|
||||
t.create_time,
|
||||
t.create_by,
|
||||
createUser.user_name as create_by_name,
|
||||
t.cost_time,
|
||||
t.remark
|
||||
from sys_mail_log t
|
||||
left join sys_user createUser on t.create_by = createUser.user_id
|
||||
<where>
|
||||
<if test="status != null ">and sys_mail_log.status = #{status}</if>
|
||||
<if test="to != null and to != ''">and sys_mail_log.to = #{to}</if>
|
||||
<if test="subject != null and subject != ''">and sys_mail_log.subject = #{subject}</if>
|
||||
<if test="status != null ">and t.status = #{status}</if>
|
||||
<if test="to != null and to != ''">and t.to = #{to}</if>
|
||||
<if test="subject != null and subject != ''">and t.subject = #{subject}</if>
|
||||
<if test="params.beginCreateTime != null and params.beginCreateTime != '' and params.endCreateTime != null and params.endCreateTime != ''">
|
||||
and create_time between #{params.beginCreateTime} and #{params.endCreateTime}
|
||||
and t.create_time between #{params.beginCreateTime} and #{params.endCreateTime}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
|
|
|||
|
|
@ -1,35 +1,38 @@
|
|||
import request from '@/utils/request'
|
||||
import request, { upload } from '@/utils/request'
|
||||
|
||||
// 查询邮件发送日志列表
|
||||
export function listMailLog(query) {
|
||||
return request({
|
||||
url: '/system/mailLog/list',
|
||||
method: 'get',
|
||||
params: query
|
||||
})
|
||||
return request({
|
||||
url: '/system/mailLog/list',
|
||||
method: 'get',
|
||||
params: query
|
||||
})
|
||||
}
|
||||
|
||||
// 查询邮件发送日志详细
|
||||
export function getMailLog(mailLogId) {
|
||||
return request({
|
||||
url: '/system/mailLog/' + mailLogId,
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
// TODO 临时邮件发送
|
||||
export function sendTemporality(data) {
|
||||
return request({
|
||||
url: '/system/mailLog/sendTemporality',
|
||||
method: 'post',
|
||||
data: data
|
||||
})
|
||||
return request({
|
||||
url: '/system/mailLog/' + mailLogId,
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
// 删除邮件发送日志
|
||||
export function delMailLog(mailLogId) {
|
||||
return request({
|
||||
url: '/system/mailLog/' + mailLogId,
|
||||
method: 'delete'
|
||||
})
|
||||
return request({
|
||||
url: '/system/mailLog/' + mailLogId,
|
||||
method: 'delete'
|
||||
})
|
||||
}
|
||||
|
||||
export function getMailSenderInfo() {
|
||||
return request({
|
||||
url: '/system/mailLog/getMailSenderInfo',
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
// 临时邮件发送
|
||||
export function sendTemporality(data, files) {
|
||||
return upload('/system/mailLog/sendTemporality', files, data)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -53,11 +53,6 @@ const {proxy} = getCurrentInstance();
|
|||
const emit = defineEmits();
|
||||
|
||||
const props = defineProps({
|
||||
// 文件数量限制
|
||||
limit: {
|
||||
type: Number,
|
||||
default: 5,
|
||||
},
|
||||
// 单个文件大小限制
|
||||
fileSize: {
|
||||
type: String,
|
||||
|
|
@ -102,16 +97,6 @@ const props = defineProps({
|
|||
},
|
||||
});
|
||||
|
||||
defineExpose({
|
||||
pond,
|
||||
getFiles,
|
||||
getFile,
|
||||
addFile,
|
||||
addFiles,
|
||||
removeFile,
|
||||
removeFiles,
|
||||
});
|
||||
|
||||
// 初始化
|
||||
function handleInit() {
|
||||
// console.info('pond.value', pond.value)
|
||||
|
|
@ -157,6 +142,15 @@ function removeFiles() {
|
|||
pond.value.removeFiles();
|
||||
}
|
||||
|
||||
defineExpose({
|
||||
getFiles,
|
||||
getFile,
|
||||
addFile,
|
||||
addFiles,
|
||||
removeFile,
|
||||
removeFiles,
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
<!--
|
||||
|
|
|
|||
|
|
@ -4,37 +4,37 @@
|
|||
<el-form-item label="发送状态" prop="status">
|
||||
<el-select v-model="queryParams.status" placeholder="请选择发送状态" clearable>
|
||||
<el-option
|
||||
v-for="dict in sys_mail_status"
|
||||
:key="dict.value"
|
||||
:label="dict.label"
|
||||
:value="dict.value"
|
||||
v-for="dict in sys_mail_status"
|
||||
:key="dict.value"
|
||||
:label="dict.label"
|
||||
:value="dict.value"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="收件人" prop="to">
|
||||
<el-input
|
||||
v-model="queryParams.to"
|
||||
placeholder="请输入收件人"
|
||||
clearable
|
||||
@keyup.enter="handleQuery"
|
||||
v-model="queryParams.to"
|
||||
placeholder="请输入收件人"
|
||||
clearable
|
||||
@keyup.enter="handleQuery"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="邮件主题" prop="subject">
|
||||
<el-input
|
||||
v-model="queryParams.subject"
|
||||
placeholder="请输入邮件主题"
|
||||
clearable
|
||||
@keyup.enter="handleQuery"
|
||||
v-model="queryParams.subject"
|
||||
placeholder="请输入邮件主题"
|
||||
clearable
|
||||
@keyup.enter="handleQuery"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="发送时间" style="width: 308px">
|
||||
<el-date-picker
|
||||
v-model="daterangeCreateTime"
|
||||
value-format="YYYY-MM-DD"
|
||||
type="daterange"
|
||||
range-separator="-"
|
||||
start-placeholder="开始日期"
|
||||
end-placeholder="结束日期"
|
||||
v-model="daterangeCreateTime"
|
||||
value-format="YYYY-MM-DD"
|
||||
type="daterange"
|
||||
range-separator="-"
|
||||
start-placeholder="开始日期"
|
||||
end-placeholder="结束日期"
|
||||
></el-date-picker>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
|
@ -48,69 +48,95 @@
|
|||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="primary"
|
||||
plain
|
||||
icon="Plus"
|
||||
@click="handleSend"
|
||||
v-hasPermi="['system:mailLog:send']"
|
||||
>临时邮件发送</el-button>
|
||||
type="primary"
|
||||
plain
|
||||
icon="Plus"
|
||||
@click="handleSend"
|
||||
v-hasPermi="['system:mailLog:send']"
|
||||
>临时邮件发送
|
||||
</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="danger"
|
||||
plain
|
||||
icon="Delete"
|
||||
:disabled="multiple"
|
||||
@click="handleDelete"
|
||||
v-hasPermi="['system:mailLog:remove']"
|
||||
>删除</el-button>
|
||||
type="danger"
|
||||
plain
|
||||
icon="Delete"
|
||||
:disabled="multiple"
|
||||
@click="handleDelete"
|
||||
v-hasPermi="['system:mailLog:remove']"
|
||||
>删除
|
||||
</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="warning"
|
||||
plain
|
||||
icon="Download"
|
||||
@click="handleExport"
|
||||
v-hasPermi="['system:mailLog:export']"
|
||||
>导出</el-button>
|
||||
type="warning"
|
||||
plain
|
||||
icon="Download"
|
||||
@click="handleExport"
|
||||
v-hasPermi="['system:mailLog:export']"
|
||||
>导出
|
||||
</el-button>
|
||||
</el-col>
|
||||
<right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
|
||||
</el-row>
|
||||
|
||||
<el-table v-loading="loading" :data="mailLogList" @selection-change="handleSelectionChange" :show-overflow-tooltip="true">
|
||||
<el-table-column type="selection" width="30" align="center" />
|
||||
<el-table-column label="日志主键" align="center" prop="mailLogId" />
|
||||
<el-table v-loading="loading" :data="mailLogList" @selection-change="handleSelectionChange"
|
||||
:show-overflow-tooltip="true">
|
||||
<el-table-column type="selection" width="30" align="center"/>
|
||||
<el-table-column label="日志ID" align="center" prop="mailLogId"/>
|
||||
<el-table-column label="发送状态" align="center" prop="status">
|
||||
<template #default="scope">
|
||||
<dict-tag :options="sys_mail_status" :value="scope.row.status"/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="自定业务类型" align="center" prop="businessType" />
|
||||
<el-table-column label="发件人" align="center" prop="from" />
|
||||
<el-table-column label="收件人" align="center" prop="to" />
|
||||
<el-table-column label="抄送" align="center" prop="cc" />
|
||||
<el-table-column label="邮件主题" align="center" prop="subject" />
|
||||
<el-table-column label="日志消息" align="center" prop="msg" />
|
||||
<el-table-column label="自定业务类型" align="center" prop="businessType"/>
|
||||
<el-table-column label="发件人" align="center" prop="from"/>
|
||||
<el-table-column label="收件人" align="center" prop="to"/>
|
||||
<el-table-column label="抄送" align="center" prop="cc"/>
|
||||
<el-table-column label="邮件主题" align="center" prop="subject"/>
|
||||
<el-table-column label="日志消息" align="center" prop="msg"/>
|
||||
<el-table-column label="发送时间" align="center" prop="createTime" width="180">
|
||||
<template #default="scope">
|
||||
<span>{{ parseTime(scope.row.createTime, '{y}-{m}-{d}') }}</span>
|
||||
<span>{{ parseTime(scope.row.createTime, '{y}-{m}-{d} {h}:{i}:{s}') }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作用户" align="center" prop="createBy" />
|
||||
<el-table-column label="消耗时间(ms)" align="center" prop="costTime" />
|
||||
<el-table-column label="操作用户" align="center" prop="createByName"/>
|
||||
<el-table-column label="消耗时间(ms)" align="center" prop="costTime"/>
|
||||
</el-table>
|
||||
|
||||
|
||||
<pagination
|
||||
v-show="total>0"
|
||||
:total="total"
|
||||
v-model:page="queryParams.pageNum"
|
||||
v-model:limit="queryParams.pageSize"
|
||||
@pagination="getList"
|
||||
v-show="total>0"
|
||||
:total="total"
|
||||
v-model:page="queryParams.pageNum"
|
||||
v-model:limit="queryParams.pageSize"
|
||||
@pagination="getList"
|
||||
/>
|
||||
|
||||
<!-- TODO 临时邮件发送对话框 -->
|
||||
<!-- 临时邮件发送对话框 -->
|
||||
<el-dialog :title="title" v-model="open" width="500px" append-to-body>
|
||||
<el-form ref="mailLogRef" :model="form" :rules="rules" label-width="80px">
|
||||
<el-form-item label="发件人" prop="from">
|
||||
<el-input v-model="form.from" placeholder="请输入发件人" disabled/>
|
||||
</el-form-item>
|
||||
<el-form-item label="收件人" prop="to">
|
||||
<el-input v-model="form.to" placeholder="请输入收件人,多个用英文分号;分隔"/>
|
||||
</el-form-item>
|
||||
<el-form-item label="抄送人" prop="cc">
|
||||
<el-input v-model="form.cc" placeholder="请输入抄送人,多个用英文分号;分隔"/>
|
||||
</el-form-item>
|
||||
<el-form-item label="邮件主题" prop="subject">
|
||||
<el-input v-model="form.subject" placeholder="请输入邮件主题"/>
|
||||
</el-form-item>
|
||||
<el-form-item label="邮件正文" prop="content">
|
||||
<el-input type="textarea" v-model="form.content" placeholder="请输入邮件正文"/>
|
||||
</el-form-item>
|
||||
<el-form-item label="附件" prop="attachmentsId">
|
||||
<fp-file-upload
|
||||
ref="fileUploadRef"
|
||||
style="width: 100%"
|
||||
:max-files-limit="5"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<div class="dialog-footer">
|
||||
|
|
@ -123,10 +149,10 @@
|
|||
</template>
|
||||
|
||||
<script setup name="MailLog">
|
||||
import { listMailLog, getMailLog, delMailLog, sendTemporality } from "@/api/system/mailLog";
|
||||
import {listMailLog, delMailLog, sendTemporality, getMailSenderInfo} from "@/api/system/mailLog";
|
||||
|
||||
const { proxy } = getCurrentInstance();
|
||||
const { sys_mail_status } = proxy.useDict('sys_mail_status');
|
||||
const {proxy} = getCurrentInstance();
|
||||
const {sys_mail_status} = proxy.useDict('sys_mail_status');
|
||||
|
||||
const mailLogList = ref([]);
|
||||
const open = ref(false);
|
||||
|
|
@ -138,6 +164,12 @@ const multiple = ref(true);
|
|||
const total = ref(0);
|
||||
const title = ref("");
|
||||
const daterangeCreateTime = ref([]);
|
||||
const senderAccount = ref({
|
||||
host: null,
|
||||
port: null,
|
||||
username: null,
|
||||
});
|
||||
const fileUploadRef = ref(null);
|
||||
|
||||
const data = reactive({
|
||||
form: {},
|
||||
|
|
@ -150,13 +182,19 @@ const data = reactive({
|
|||
createTime: null,
|
||||
},
|
||||
rules: {
|
||||
status: [
|
||||
{ required: true, message: "发送状态不能为空", trigger: "change" },
|
||||
from: [
|
||||
{required: true, message: "发件人不能为空", trigger: "change"},
|
||||
],
|
||||
to: [
|
||||
{required: true, message: "收件人不能为空", trigger: "change"},
|
||||
],
|
||||
subject: [
|
||||
{required: true, message: "邮件主题不能为空", trigger: "change"},
|
||||
],
|
||||
}
|
||||
});
|
||||
|
||||
const { queryParams, form, rules } = toRefs(data);
|
||||
const {queryParams, form, rules} = toRefs(data);
|
||||
|
||||
/** 查询邮件发送日志列表 */
|
||||
function getList() {
|
||||
|
|
@ -189,12 +227,12 @@ function reset() {
|
|||
to: null,
|
||||
cc: null,
|
||||
subject: null,
|
||||
msg: null,
|
||||
createTime: null,
|
||||
createBy: null,
|
||||
costTime: null,
|
||||
remark: null
|
||||
content: null,
|
||||
attachmentsId: null,
|
||||
};
|
||||
if (fileUploadRef.value) {
|
||||
fileUploadRef.value.removeFiles();
|
||||
}
|
||||
proxy.resetForm("mailLogRef");
|
||||
}
|
||||
|
||||
|
|
@ -218,18 +256,34 @@ function handleSelectionChange(selection) {
|
|||
multiple.value = !selection.length;
|
||||
}
|
||||
|
||||
/** 新增按钮操作 */
|
||||
/** 临时邮件发送按钮操作 */
|
||||
function handleSend() {
|
||||
reset();
|
||||
open.value = true;
|
||||
title.value = "临时邮件发送";
|
||||
form.value.from = senderAccount.value.username;
|
||||
}
|
||||
|
||||
/** 提交按钮 */
|
||||
function submitForm() {
|
||||
proxy.$refs["mailLogRef"].validate(valid => {
|
||||
if (valid) {
|
||||
//TODO 临时邮件发送待完成
|
||||
const files = fileUploadRef.value.getFiles();
|
||||
const submitFiles = [];
|
||||
for (let i = 0; i < files.length; i++) {
|
||||
submitFiles.push({
|
||||
key: 'attachments',
|
||||
value: files[i],
|
||||
})
|
||||
}
|
||||
sendTemporality(form.value, submitFiles)
|
||||
.then(() => {
|
||||
proxy.$modal.msgSuccess("发送成功");
|
||||
})
|
||||
.finally(() => {
|
||||
open.value = false;
|
||||
getList();
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
@ -237,12 +291,13 @@ function submitForm() {
|
|||
/** 删除按钮操作 */
|
||||
function handleDelete(row) {
|
||||
const _mailLogIds = row.mailLogId || ids.value;
|
||||
proxy.$modal.confirm('是否确认删除邮件发送日志编号为"' + _mailLogIds + '"的数据项?').then(function() {
|
||||
proxy.$modal.confirm('是否确认删除邮件发送日志编号为"' + _mailLogIds + '"的数据项?').then(function () {
|
||||
return delMailLog(_mailLogIds);
|
||||
}).then(() => {
|
||||
getList();
|
||||
proxy.$modal.msgSuccess("删除成功");
|
||||
}).catch(() => {});
|
||||
}).catch(() => {
|
||||
});
|
||||
}
|
||||
|
||||
/** 导出按钮操作 */
|
||||
|
|
@ -252,6 +307,16 @@ function handleExport() {
|
|||
}, `mailLog_${new Date().getTime()}.xlsx`)
|
||||
}
|
||||
|
||||
//页面打开时查询
|
||||
/** 获取发件人账号 */
|
||||
function getMailSenderAccount() {
|
||||
getMailSenderInfo().then(response => {
|
||||
senderAccount.value = response.data;
|
||||
});
|
||||
}
|
||||
|
||||
// 页面打开时查询发送者账号
|
||||
getMailSenderAccount();
|
||||
|
||||
// 页面打开时查询
|
||||
//getList();
|
||||
</script>
|
||||
|
|
|
|||
|
|
@ -108,7 +108,6 @@
|
|||
<script setup name="InvTransHis">
|
||||
import { listInvTransHis } from "@/api/wms/InvTransHis";
|
||||
import { listWarehouseInfo } from "@/api/wms/WarehouseInfo";
|
||||
import DataSelect from "@/components/DataSelect/index.vue";
|
||||
|
||||
const { proxy } = getCurrentInstance();
|
||||
const {wms_inv_trans_type} = proxy.useDict("wms_inv_trans_type");
|
||||
|
|
|
|||
|
|
@ -549,6 +549,9 @@ function reset() {
|
|||
remark4: null,
|
||||
remark5: null,
|
||||
};
|
||||
if (fileUpload.value) {
|
||||
fileUpload.value.removeFiles();
|
||||
}
|
||||
proxy.resetForm("ItemInfoRef");
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
Target Server Version : 80200 (8.2.0)
|
||||
File Encoding : 65001
|
||||
|
||||
Date: 01/03/2024 14:30:57
|
||||
Date: 04/03/2024 16:13:20
|
||||
*/
|
||||
|
||||
SET NAMES utf8mb4;
|
||||
|
|
@ -572,7 +572,7 @@ CREATE TABLE `sys_config` (
|
|||
`update_time` datetime NULL DEFAULT NULL COMMENT '更新时间',
|
||||
`remark` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '备注',
|
||||
PRIMARY KEY (`config_id`) USING BTREE
|
||||
) ENGINE = InnoDB AUTO_INCREMENT = 104 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_bin COMMENT = '参数配置表' ROW_FORMAT = Dynamic;
|
||||
) ENGINE = InnoDB AUTO_INCREMENT = 105 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_bin COMMENT = '参数配置表' ROW_FORMAT = Dynamic;
|
||||
|
||||
-- ----------------------------
|
||||
-- Records of sys_config
|
||||
|
|
@ -583,9 +583,10 @@ INSERT INTO `sys_config` VALUES (3, '主框架页-侧边栏主题', 'sys.index.s
|
|||
INSERT INTO `sys_config` VALUES (4, '账号自助-是否开启用户注册功能', 'sys.account.registerUser', 'false', 'Y', 'admin', '2024-01-30 05:05:41', '', NULL, '是否开启注册用户功能(true开启,false关闭)');
|
||||
INSERT INTO `sys_config` VALUES (5, '用户登录-黑名单列表', 'sys.login.blackIPList', '', 'Y', 'admin', '2024-01-30 05:05:41', '', NULL, '设置登录IP黑名单限制,多个匹配项以;分隔,支持匹配(*通配、网段)');
|
||||
INSERT INTO `sys_config` VALUES (100, '邮件-SMTP服务器', 'sys.mail.smtpHost', 'smtp.test.com', 'Y', 'admin', '2024-03-01 10:05:41', '', NULL, '');
|
||||
INSERT INTO `sys_config` VALUES (101, '邮件-SMTP服务器端口', 'sys.mail.smtpPort', '495', 'Y', 'admin', '2024-03-01 10:05:41', '', NULL, '');
|
||||
INSERT INTO `sys_config` VALUES (102, '邮件-认证用户名', 'sys.mail.username', 'testUser', 'Y', 'admin', '2024-03-01 10:05:41', '', NULL, '也会作为默认发件人');
|
||||
INSERT INTO `sys_config` VALUES (101, '邮件-SMTP服务器端口', 'sys.mail.smtpPort', '587', 'Y', 'admin', '2024-03-01 10:05:41', '', NULL, '');
|
||||
INSERT INTO `sys_config` VALUES (102, '邮件-认证用户名', 'sys.mail.username', 'sender@test.com', 'Y', 'admin', '2024-03-01 10:05:41', '', NULL, '也会作为默认发件人');
|
||||
INSERT INTO `sys_config` VALUES (103, '邮件-认证密码', 'sys.mail.password', 'abcdefg', 'Y', 'admin', '2024-03-01 10:05:41', '', NULL, '');
|
||||
INSERT INTO `sys_config` VALUES (104, '邮件-附件保存地址', 'sys.mail.attachmentsSavedPath', 'D:\\temp\\RYAS\\mailAttachments', 'Y', 'admin', '2024-03-04 10:05:41', '', NULL, '');
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for sys_dept
|
||||
|
|
@ -833,7 +834,7 @@ CREATE TABLE `sys_logininfor` (
|
|||
PRIMARY KEY (`info_id`) USING BTREE,
|
||||
INDEX `idx_sys_logininfor_s`(`status` ASC) USING BTREE,
|
||||
INDEX `idx_sys_logininfor_lt`(`access_time` ASC) USING BTREE
|
||||
) ENGINE = InnoDB AUTO_INCREMENT = 156 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_bin COMMENT = '系统访问记录' ROW_FORMAT = Dynamic;
|
||||
) ENGINE = InnoDB AUTO_INCREMENT = 157 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_bin COMMENT = '系统访问记录' ROW_FORMAT = Dynamic;
|
||||
|
||||
-- ----------------------------
|
||||
-- Records of sys_logininfor
|
||||
|
|
@ -851,7 +852,7 @@ CREATE TABLE `sys_mail_log` (
|
|||
`to` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT '' COMMENT '收件人',
|
||||
`cc` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT '' COMMENT '抄送',
|
||||
`subject` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT '0' COMMENT '邮件主题',
|
||||
`msg` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT '' COMMENT '日志消息',
|
||||
`msg` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT '' COMMENT '日志消息',
|
||||
`create_time` datetime NULL DEFAULT NULL COMMENT '发送时间',
|
||||
`create_by` bigint NULL DEFAULT 0 COMMENT '操作用户',
|
||||
`cost_time` bigint NULL DEFAULT NULL COMMENT '消耗时间(ms)',
|
||||
|
|
@ -1080,21 +1081,11 @@ CREATE TABLE `sys_oper_log` (
|
|||
INDEX `idx_sys_oper_log_bt`(`business_type` ASC) USING BTREE,
|
||||
INDEX `idx_sys_oper_log_s`(`status` ASC) USING BTREE,
|
||||
INDEX `idx_sys_oper_log_ot`(`oper_time` ASC) USING BTREE
|
||||
) ENGINE = InnoDB AUTO_INCREMENT = 302 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_bin COMMENT = '操作日志记录' ROW_FORMAT = Dynamic;
|
||||
) ENGINE = InnoDB AUTO_INCREMENT = 319 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_bin COMMENT = '操作日志记录' ROW_FORMAT = Dynamic;
|
||||
|
||||
-- ----------------------------
|
||||
-- Records of sys_oper_log
|
||||
-- ----------------------------
|
||||
INSERT INTO `sys_oper_log` VALUES (292, '代码生成', 6, 'com.ruoyi.gen.controller.GenController.importTableSave()', 'POST', 1, 'admin', NULL, '/gen/importTable', '127.0.0.1', '', '{\"tables\":\"sys_mail_log\"}', '{\"msg\":\"操作成功\",\"code\":200}', 0, NULL, '2024-03-01 06:05:08', 781);
|
||||
INSERT INTO `sys_oper_log` VALUES (293, '代码生成', 2, 'com.ruoyi.gen.controller.GenController.editSave()', 'PUT', 1, 'admin', NULL, '/gen', '127.0.0.1', '', '{\"businessName\":\"mailLog\",\"className\":\"SysMailLog\",\"columns\":[{\"capJavaField\":\"MailLogId\",\"columnComment\":\"日志主键\",\"columnId\":380,\"columnName\":\"mail_log_id\",\"columnType\":\"bigint\",\"createBy\":\"admin\",\"createTime\":\"2024-03-01 06:05:07\",\"dictType\":\"\",\"edit\":false,\"htmlType\":\"input\",\"increment\":false,\"insert\":true,\"isIncrement\":\"0\",\"isInsert\":\"1\",\"isPk\":\"1\",\"javaField\":\"mailLogId\",\"javaType\":\"Long\",\"list\":false,\"params\":{},\"pk\":true,\"query\":false,\"queryType\":\"EQ\",\"required\":false,\"sort\":1,\"superColumn\":false,\"tableId\":19,\"updateBy\":\"\",\"usableColumn\":false},{\"capJavaField\":\"Status\",\"columnComment\":\"发送状态(0未发送 1成功 2失败)\",\"columnId\":381,\"columnName\":\"status\",\"columnType\":\"int\",\"createBy\":\"admin\",\"createTime\":\"2024-03-01 06:05:07\",\"dictType\":\"\",\"edit\":true,\"htmlType\":\"radio\",\"increment\":false,\"insert\":true,\"isEdit\":\"1\",\"isIncrement\":\"0\",\"isInsert\":\"1\",\"isList\":\"1\",\"isPk\":\"0\",\"isQuery\":\"1\",\"isRequired\":\"1\",\"javaField\":\"status\",\"javaType\":\"Long\",\"list\":true,\"params\":{},\"pk\":false,\"query\":true,\"queryType\":\"EQ\",\"required\":true,\"sort\":2,\"superColumn\":false,\"tableId\":19,\"updateBy\":\"\",\"usableColumn\":false},{\"capJavaField\":\"BusinessType\",\"columnComment\":\"自定业务类型\",\"columnId\":382,\"columnName\":\"business_type\",\"columnType\":\"varchar(30)\",\"createBy\":\"admin\",\"createTime\":\"2024-03-01 06:05:07\",\"dictType\":\"\",\"edit\":true,\"htmlType\":\"select\",\"increment\":false,\"insert\":true,\"isEdit\":\"1\",\"isIncrement\":\"0\",\"isInsert\":\"1\",\"isList\":\"1\",\"isPk\":\"0\",\"isQuery\":\"0\",\"javaField\":\"businessType\",\"javaType\":\"String\",\"list\":true,\"params\":{},\"pk\":false,\"query\":false,\"queryType\":\"EQ\",\"required\":false,\"sort\":3,\"superColumn\":false,\"tableId\":19,\"updateBy\":\"\",\"usableColumn\":false},{\"capJavaField\":\"From\",\"columnComment\":\"发件人\",\"columnId\":383,\"columnName\":\"from\",\"columnType\":\"varchar(255)\",\"createBy\":\"admin\",\"createTime\":\"2024-03-01 06:05:07\",\"dictType\":\"\",\"edit\":true,\"htmlType\":\"input\",\"increment\":false,\"insert\":true,\"isEdit\":\"1\",\"isIncrement\":\"0\",\"isInsert\":\"1\",\"isList\":\"1\",\"isPk\":\"0\",\"isQuery\":\"0\",\"javaField\":\"from\",\"ja', '{\"msg\":\"操作成功\",\"code\":200}', 0, NULL, '2024-03-01 06:08:03', 454);
|
||||
INSERT INTO `sys_oper_log` VALUES (294, '字典类型', 1, 'com.ruoyi.system.controller.SysDictTypeController.add()', 'POST', 1, 'admin', NULL, '/dict/type', '127.0.0.1', '', '{\"createBy\":\"1\",\"createTime\":\"2024-03-01 14:08:28\",\"dictName\":\"邮件发送状态\",\"dictType\":\"sys_mail_status\",\"params\":{},\"status\":\"0\",\"updateBy\":\"1\",\"updateTime\":\"2024-03-01 14:08:28\"}', '{\"msg\":\"操作成功\",\"code\":200}', 0, NULL, '2024-03-01 06:08:29', 69);
|
||||
INSERT INTO `sys_oper_log` VALUES (295, '字典数据', 1, 'com.ruoyi.system.controller.SysDictDataController.add()', 'POST', 1, 'admin', NULL, '/dict/data', '127.0.0.1', '', '{\"createBy\":\"1\",\"createTime\":\"2024-03-01 14:09:05\",\"default\":false,\"dictLabel\":\"未发送\",\"dictSort\":1,\"dictType\":\"sys_mail_status\",\"dictValue\":\"0\",\"listClass\":\"default\",\"params\":{},\"status\":\"0\",\"updateBy\":\"1\",\"updateTime\":\"2024-03-01 14:09:05\"}', '{\"msg\":\"操作成功\",\"code\":200}', 0, NULL, '2024-03-01 06:09:05', 54);
|
||||
INSERT INTO `sys_oper_log` VALUES (296, '字典数据', 1, 'com.ruoyi.system.controller.SysDictDataController.add()', 'POST', 1, 'admin', NULL, '/dict/data', '127.0.0.1', '', '{\"createBy\":\"1\",\"createTime\":\"2024-03-01 14:09:17\",\"default\":false,\"dictLabel\":\"发送成功\",\"dictSort\":2,\"dictType\":\"sys_mail_status\",\"dictValue\":\"1\",\"listClass\":\"success\",\"params\":{},\"status\":\"0\",\"updateBy\":\"1\",\"updateTime\":\"2024-03-01 14:09:17\"}', '{\"msg\":\"操作成功\",\"code\":200}', 0, NULL, '2024-03-01 06:09:17', 46);
|
||||
INSERT INTO `sys_oper_log` VALUES (297, '字典数据', 1, 'com.ruoyi.system.controller.SysDictDataController.add()', 'POST', 1, 'admin', NULL, '/dict/data', '127.0.0.1', '', '{\"createBy\":\"1\",\"createTime\":\"2024-03-01 14:09:30\",\"default\":false,\"dictLabel\":\"发送失败\",\"dictSort\":3,\"dictType\":\"sys_mail_status\",\"dictValue\":\"2\",\"listClass\":\"danger\",\"params\":{},\"status\":\"0\",\"updateBy\":\"1\",\"updateTime\":\"2024-03-01 14:09:30\"}', '{\"msg\":\"操作成功\",\"code\":200}', 0, NULL, '2024-03-01 06:09:30', 40);
|
||||
INSERT INTO `sys_oper_log` VALUES (298, '代码生成', 2, 'com.ruoyi.gen.controller.GenController.editSave()', 'PUT', 1, 'admin', NULL, '/gen', '127.0.0.1', '', '{\"businessName\":\"mailLog\",\"className\":\"SysMailLog\",\"columns\":[{\"capJavaField\":\"MailLogId\",\"columnComment\":\"日志主键\",\"columnId\":380,\"columnName\":\"mail_log_id\",\"columnType\":\"bigint\",\"createBy\":\"admin\",\"createTime\":\"2024-03-01 06:05:07\",\"dictType\":\"\",\"edit\":false,\"htmlType\":\"input\",\"increment\":false,\"insert\":false,\"isIncrement\":\"0\",\"isInsert\":\"0\",\"isPk\":\"1\",\"javaField\":\"mailLogId\",\"javaType\":\"Long\",\"list\":false,\"params\":{},\"pk\":true,\"query\":false,\"queryType\":\"EQ\",\"required\":false,\"sort\":1,\"superColumn\":false,\"tableId\":19,\"updateBy\":\"\",\"updateTime\":\"2024-03-01 06:08:03\",\"usableColumn\":false},{\"capJavaField\":\"Status\",\"columnComment\":\"发送状态(0未发送 1成功 2失败)\",\"columnId\":381,\"columnName\":\"status\",\"columnType\":\"int\",\"createBy\":\"admin\",\"createTime\":\"2024-03-01 06:05:07\",\"dictType\":\"sys_mail_status\",\"edit\":false,\"htmlType\":\"radio\",\"increment\":false,\"insert\":false,\"isEdit\":\"0\",\"isIncrement\":\"0\",\"isInsert\":\"0\",\"isList\":\"1\",\"isPk\":\"0\",\"isQuery\":\"1\",\"isRequired\":\"1\",\"javaField\":\"status\",\"javaType\":\"Long\",\"list\":true,\"params\":{},\"pk\":false,\"query\":true,\"queryType\":\"EQ\",\"required\":true,\"sort\":2,\"superColumn\":false,\"tableId\":19,\"updateBy\":\"\",\"updateTime\":\"2024-03-01 06:08:03\",\"usableColumn\":false},{\"capJavaField\":\"BusinessType\",\"columnComment\":\"自定业务类型\",\"columnId\":382,\"columnName\":\"business_type\",\"columnType\":\"varchar(30)\",\"createBy\":\"admin\",\"createTime\":\"2024-03-01 06:05:07\",\"dictType\":\"\",\"edit\":false,\"htmlType\":\"select\",\"increment\":false,\"insert\":false,\"isEdit\":\"0\",\"isIncrement\":\"0\",\"isInsert\":\"0\",\"isList\":\"1\",\"isPk\":\"0\",\"isQuery\":\"0\",\"javaField\":\"businessType\",\"javaType\":\"String\",\"list\":true,\"params\":{},\"pk\":false,\"query\":false,\"queryType\":\"EQ\",\"required\":false,\"sort\":3,\"superColumn\":false,\"tableId\":19,\"updateBy\":\"\",\"updateTime\":\"2024-03-01 06:08:03\",\"usableColumn\":false},{\"capJavaField\":\"From\",\"columnComment\":\"发件人\",\"columnId\":383,\"columnName\":\"from\",\"columnType\":\"varchar(255)\",\"createBy\":\"admin\",\"createTime\":\"2024-03-01 06:05:07\",\"dictType\":\"\",\"edit\":false,\"htmlType\":\"input\",\"increment\":', '{\"msg\":\"操作成功\",\"code\":200}', 0, NULL, '2024-03-01 06:10:19', 687);
|
||||
INSERT INTO `sys_oper_log` VALUES (299, '代码生成', 8, 'com.ruoyi.gen.controller.GenController.batchGenCode()', 'GET', 1, 'admin', NULL, '/gen/batchGenCode', '127.0.0.1', '', '{\"tables\":\"sys_mail_log\"}', NULL, 0, NULL, '2024-03-01 06:10:23', 348);
|
||||
INSERT INTO `sys_oper_log` VALUES (300, '代码生成', 8, 'com.ruoyi.gen.controller.GenController.batchGenCode()', 'GET', 1, 'admin', NULL, '/gen/batchGenCode', '127.0.0.1', '', '{\"tables\":\"sys_mail_log\"}', NULL, 0, NULL, '2024-03-01 06:10:51', 120);
|
||||
INSERT INTO `sys_oper_log` VALUES (301, '菜单管理', 2, 'com.ruoyi.system.controller.SysMenuController.edit()', 'PUT', 1, 'admin', NULL, '/menu', '127.0.0.1', '', '{\"children\":[],\"component\":\"system/mailLog/index\",\"createTime\":\"2024-03-01 06:23:24\",\"icon\":\"email\",\"isCache\":\"0\",\"isFrame\":\"1\",\"menuId\":2054,\"menuName\":\"邮件发送日志\",\"menuType\":\"C\",\"orderNum\":3,\"params\":{},\"parentId\":108,\"path\":\"mailLog\",\"perms\":\"system:mailLog:list\",\"status\":\"0\",\"updateBy\":\"1\",\"updateTime\":\"2024-03-01 14:25:42\",\"visible\":\"0\"}', '{\"msg\":\"操作成功\",\"code\":200}', 0, NULL, '2024-03-01 06:25:43', 79);
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for sys_post
|
||||
|
|
|
|||
Loading…
Reference in New Issue