简单邮件发送功能完成

pull/362/head
AlanScipio 2 years ago
parent 932b4da710
commit 24f1f4c3e7

@ -53,6 +53,17 @@ public class SpringMailSender implements MailSender {
//超时设置 //超时设置
mailProperties.setProperty("mail.smtp.connectiontimeout", timeout + "");//与邮件服务器建立连接的超时 mailProperties.setProperty("mail.smtp.connectiontimeout", timeout + "");//与邮件服务器建立连接的超时
mailProperties.setProperty("mail.smtp.writetimeout", 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()) { if (account.isSslFlag()) {
//开启ssl //开启ssl
System.out.println("****** enable ssl for mail send ******"); System.out.println("****** enable ssl for mail send ******");
@ -61,18 +72,14 @@ public class SpringMailSender implements MailSender {
mailProperties.setProperty("mail.smtp.ssl.enable", "true"); mailProperties.setProperty("mail.smtp.ssl.enable", "true");
} else { } else {
System.out.println("****** disable ssl for mail send ******"); System.out.println("****** disable ssl for mail send ******");
javaMailSender.setPort(account.getPort()); executor.setPort(account.getPort() == null ? 25 : account.getPort());
} }
javaMailSender.setJavaMailProperties(mailProperties); executor.setJavaMailProperties(mailProperties);
javaMailSender.setHost(account.getHost()); executor.setHost(account.getHost());
javaMailSender.setUsername(account.getUsername()); executor.setUsername(account.getUsername());
javaMailSender.setPassword(account.getPassword()); executor.setPassword(account.getPassword());
javaMailSender.setDefaultEncoding("UTF-8");
System.setProperty("mail.mime.splitlongparameters", "false"); //注意不截断base64编码后的长附件名
return javaMailSender;
} }
/** /**
* *
* *
@ -90,13 +97,13 @@ public class SpringMailSender implements MailSender {
//创建发送MIME邮件的工具类 //创建发送MIME邮件的工具类
MimeMessageHelper messageHelper = getMimeMessageHelper(form, mimeMessage, headInfo); MimeMessageHelper messageHelper = getMimeMessageHelper(form, mimeMessage, headInfo);
//设置正文多媒体信息 //设置正文多媒体信息
if (inLineMap != null) { if (inLineMap != null && !inLineMap.isEmpty()) {
for (Map.Entry<String, File> inLine : inLineMap.entrySet()) { for (Map.Entry<String, File> inLine : inLineMap.entrySet()) {
messageHelper.addInline(inLine.getKey(), inLine.getValue()); messageHelper.addInline(inLine.getKey(), inLine.getValue());
} }
} }
//添加附件 //添加附件
if (attachments != null) { if (attachments != null && !attachments.isEmpty()) {
for (Map.Entry<String, File> entry : attachments.entrySet()) { for (Map.Entry<String, File> entry : attachments.entrySet()) {
String fileName = entry.getKey(); String fileName = entry.getKey();
File file = entry.getValue(); File file = entry.getValue();
@ -111,9 +118,8 @@ public class SpringMailSender implements MailSender {
//发件人 //发件人
if (form.getFrom() == null || form.getFrom().isEmpty()) { if (form.getFrom() == null || form.getFrom().isEmpty()) {
form.setFrom(senderAccount.getUsername()); form.setFrom(senderAccount.getUsername());
} else {
form.setFrom(form.getFrom());
} }
messageHelper.setFrom(form.getFrom());
//收件人 这里的参数可以是多个收件人,用英文分号分割 //收件人 这里的参数可以是多个收件人,用英文分号分割
messageHelper.setTo(headInfo.getTo().split(ADDRESS_SPLIT)); messageHelper.setTo(headInfo.getTo().split(ADDRESS_SPLIT));
//抄送 这里的参数可以是多个抄送人,用英文分号分割 //抄送 这里的参数可以是多个抄送人,用英文分号分割
@ -125,6 +131,8 @@ public class SpringMailSender implements MailSender {
//邮件正文 //邮件正文
if (form.getContent() != null && !form.getContent().isEmpty()) { if (form.getContent() != null && !form.getContent().isEmpty()) {
messageHelper.setText(form.getContent(), form.isHtml()); messageHelper.setText(form.getContent(), form.isHtml());
} else {
messageHelper.setText("");
} }
return messageHelper; return messageHelper;
} }
@ -160,6 +168,7 @@ public class SpringMailSender implements MailSender {
public void resetSenderAccount(MailSendAccount senderAccount) { public void resetSenderAccount(MailSendAccount senderAccount) {
checkAccount(senderAccount); checkAccount(senderAccount);
this.senderAccount = senderAccount; this.senderAccount = senderAccount;
setAuthInfo(executor, senderAccount, null);
} }
private void checkAccount(MailSendAccount account) { 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.mail.MailSender;
import com.ruoyi.common.core.utils.StringUtils; import com.ruoyi.common.core.utils.StringUtils;
import com.ruoyi.common.security.utils.SysConfigUtils; import com.ruoyi.common.security.utils.SysConfigUtils;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import java.io.File;
/** /**
* *
* *
@ -28,6 +31,12 @@ public class MailConfig {
@Value("${spring.mail.password:#{null}}") @Value("${spring.mail.password:#{null}}")
private String password; private String password;
@Getter
private File attachmentsSavedDir;
private MailSender mailSender;
@Bean @Bean
public MailSender mailSender() { public MailSender mailSender() {
MailSendAccount account = new MailSendAccount(); MailSendAccount account = new MailSendAccount();
@ -38,11 +47,27 @@ public class MailConfig {
account.setUsername(username); account.setUsername(username);
account.setPassword(password); 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中并覆盖前面的配置 // 加载数据库中的邮件配置会缓存到redis中并覆盖前面的配置
String hostCache = SysConfigUtils.getConfigCache("sys.mail.smtpHost"); String hostCache = SysConfigUtils.getConfigCache("sys.mail.smtpHost");
String portCache = SysConfigUtils.getConfigCache("sys.mail.smtpPort"); String portCache = SysConfigUtils.getConfigCache("sys.mail.smtpPort");
String usernameCache = SysConfigUtils.getConfigCache("sys.mail.username"); String usernameCache = SysConfigUtils.getConfigCache("sys.mail.username");
String passwordCache = SysConfigUtils.getConfigCache("sys.mail.password"); String passwordCache = SysConfigUtils.getConfigCache("sys.mail.password");
String attachmentsSavedPath = SysConfigUtils.getConfigCache("sys.mail.attachmentsSavedPath");
if (StringUtils.isNotBlank(hostCache) && StringUtils.isNotBlank(portCache)) { if (StringUtils.isNotBlank(hostCache) && StringUtils.isNotBlank(portCache)) {
account.setHost(hostCache); account.setHost(hostCache);
account.setPort(Integer.parseInt(portCache)); account.setPort(Integer.parseInt(portCache));
@ -52,13 +77,27 @@ public class MailConfig {
if (StringUtils.isNotBlank(passwordCache)) { if (StringUtils.isNotBlank(passwordCache)) {
account.setPassword(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 { } else {
log.warn("Mail configuration from database table 'sys_config' is empty. Use the configuration from application.yaml instead."); 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()); 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; package com.ruoyi.system.controller;
import com.ruoyi.common.core.mail.MailMessage;
import com.ruoyi.common.core.mail.MailSendResult; import com.ruoyi.common.core.mail.MailSendResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil; import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.controller.BaseController; 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.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions; import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.system.domain.SysMailLog; import com.ruoyi.system.domain.SysMailLog;
import com.ruoyi.system.domain.vo.MailVo;
import com.ruoyi.system.service.ISysMailLogService; import com.ruoyi.system.service.ISysMailLogService;
import jakarta.servlet.http.HttpServletResponse; import jakarta.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -61,14 +61,24 @@ public class SysMailLogController extends BaseController {
return success(sysMailLogService.selectSysMailLogByMailLogId(mailLogId)); return success(sysMailLogService.selectSysMailLogByMailLogId(mailLogId));
} }
/**
*
*/
@RequiresPermissions("system:mailLog:remove")
@Log(title = "邮件发送日志", businessType = BusinessType.DELETE)
@DeleteMapping("/{mailLogIds}")
public AjaxResult remove(@PathVariable Long[] mailLogIds) {
return toAjax(sysMailLogService.deleteSysMailLogByMailLogIds(mailLogIds));
}
/** /**
* *
*/ */
@RequiresPermissions("system:mailLog:send") @RequiresPermissions("system:mailLog:send")
@Log(title = "临时邮件发送", businessType = BusinessType.OTHER) @Log(title = "临时邮件发送", businessType = BusinessType.OTHER)
@PostMapping("/sendTemporality") @PostMapping("/sendTemporality")
public AjaxResult sendTemporality(@RequestBody MailMessage message) { public AjaxResult sendTemporality(MailVo mailVo) {
MailSendResult result = sysMailLogService.sendTempMail(message); MailSendResult result = sysMailLogService.sendSimpleMail(mailVo);
if (result.isSuccess()) { if (result.isSuccess()) {
return success(); return success();
} else { } else {
@ -77,12 +87,11 @@ public class SysMailLogController extends BaseController {
} }
/** /**
* *
*/ */
@RequiresPermissions("system:mailLog:remove") @RequiresPermissions("system:mailLog:query")
@Log(title = "邮件发送日志", businessType = BusinessType.DELETE) @GetMapping(value = "/getMailSenderInfo")
@DeleteMapping("/{mailLogIds}") public AjaxResult getMailSenderInfo() {
public AjaxResult remove(@PathVariable Long[] mailLogIds) { return success(sysMailLogService.getMailSenderInfo());
return toAjax(sysMailLogService.deleteSysMailLogByMailLogIds(mailLogIds));
} }
} }

@ -1,9 +1,10 @@
package com.ruoyi.system.domain; 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.annotation.Excel;
import com.ruoyi.common.core.web.domain.BaseEntity; import com.ruoyi.common.core.web.domain.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import java.io.Serial; import java.io.Serial;
@ -13,10 +14,22 @@ import java.io.Serial;
* @author ryas * @author ryas
* created on 2024-03-01 * created on 2024-03-01
*/ */
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true)
@Data
public class SysMailLog extends BaseEntity { public class SysMailLog extends BaseEntity {
@Serial @Serial
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
//==================== ↓↓↓↓↓↓ 非表字段 ↓↓↓↓↓↓ ====================
/**
*
*/
private String createByName;
//==================== ↓↓↓↓↓↓ 表字段 ↓↓↓↓↓↓ ====================
/** /**
* *
*/ */
@ -70,93 +83,4 @@ public class SysMailLog extends BaseEntity {
@Excel(name = "消耗时间(ms)") @Excel(name = "消耗时间(ms)")
private Long costTime; 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; 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.common.core.mail.MailSendResult;
import com.ruoyi.system.domain.SysMailLog; import com.ruoyi.system.domain.SysMailLog;
import com.ruoyi.system.domain.vo.MailVo;
import java.util.List; import java.util.List;
@ -62,10 +63,15 @@ public interface ISysMailLogService {
int deleteSysMailLogByMailLogId(Long mailLogId); int deleteSysMailLogByMailLogId(Long mailLogId);
/** /**
* * -
* *
* @param message * @param mailVo
* @return * @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.text.Convert;
import com.ruoyi.common.core.utils.StringUtils; import com.ruoyi.common.core.utils.StringUtils;
import com.ruoyi.common.redis.service.RedisService; import com.ruoyi.common.redis.service.RedisService;
import com.ruoyi.system.config.MailConfig;
import com.ruoyi.system.domain.SysConfig; import com.ruoyi.system.domain.SysConfig;
import com.ruoyi.system.mapper.SysConfigMapper; import com.ruoyi.system.mapper.SysConfigMapper;
import com.ruoyi.system.service.ISysConfigService; import com.ruoyi.system.service.ISysConfigService;
@ -29,6 +30,9 @@ public class SysConfigServiceImpl implements ISysConfigService {
@Resource @Resource
private RedisService redisService; private RedisService redisService;
@Resource
private MailConfig mailConfig;
/** /**
* *
*/ */
@ -167,6 +171,7 @@ public class SysConfigServiceImpl implements ISysConfigService {
public void resetConfigCache() { public void resetConfigCache() {
clearConfigCache(); clearConfigCache();
loadingConfigCache(); loadingConfigCache();
mailConfig.refreshCache();
} }
/** /**

@ -1,17 +1,29 @@
package com.ruoyi.system.service.impl; package com.ruoyi.system.service.impl;
import com.ruoyi.common.core.mail.MailMessage; 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.MailSendResult;
import com.ruoyi.common.core.mail.MailSender; import com.ruoyi.common.core.mail.MailSender;
import com.ruoyi.common.core.utils.DateUtils; 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.common.core.utils.uuid.snowflake.SnowFlakeIdGenerator;
import com.ruoyi.system.config.MailConfig;
import com.ruoyi.system.domain.SysMailLog; import com.ruoyi.system.domain.SysMailLog;
import com.ruoyi.system.domain.vo.MailVo;
import com.ruoyi.system.mapper.SysMailLogMapper; import com.ruoyi.system.mapper.SysMailLogMapper;
import com.ruoyi.system.service.ISysMailLogService; import com.ruoyi.system.service.ISysMailLogService;
import jakarta.annotation.Resource; import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.mail.MailSendException;
import org.springframework.stereotype.Service; 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.List;
import java.util.Objects;
/** /**
* Service * Service
@ -19,6 +31,7 @@ import java.util.List;
* @author ryas * @author ryas
* created on 2024-03-01 * created on 2024-03-01
*/ */
@Slf4j
@Service @Service
public class SysMailLogServiceImpl implements ISysMailLogService { public class SysMailLogServiceImpl implements ISysMailLogService {
@ -28,6 +41,9 @@ public class SysMailLogServiceImpl implements ISysMailLogService {
@Resource @Resource
private MailSender mailSender; private MailSender mailSender;
@Resource
private MailConfig mailConfig;
/** /**
* *
* *
@ -62,6 +78,9 @@ public class SysMailLogServiceImpl implements ISysMailLogService {
if (sysMailLog.getMailLogId() == null) { if (sysMailLog.getMailLogId() == null) {
sysMailLog.setMailLogId(SnowFlakeIdGenerator.nextIdLong()); sysMailLog.setMailLogId(SnowFlakeIdGenerator.nextIdLong());
} }
if (StringUtils.isNotBlank(sysMailLog.getMsg()) && sysMailLog.getMsg().length() > 500) {
sysMailLog.setMsg(sysMailLog.getMsg().substring(0, 500));
}
return sysMailLogMapper.insertSysMailLog(sysMailLog); return sysMailLogMapper.insertSysMailLog(sysMailLog);
} }
@ -73,6 +92,9 @@ public class SysMailLogServiceImpl implements ISysMailLogService {
*/ */
@Override @Override
public int updateSysMailLog(SysMailLog sysMailLog) { 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); return sysMailLogMapper.updateSysMailLog(sysMailLog);
} }
@ -99,14 +121,146 @@ public class SysMailLogServiceImpl implements ISysMailLogService {
} }
/** /**
* * -
* *
* @param message * @param mailVo
* @return * @return
*/ */
@Override @Override
public MailSendResult sendTempMail(MailMessage message) { public MailSendResult sendSimpleMail(MailVo mailVo) {
//TODO 待完成 // 参数校验
return null; 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="msg" column="msg"/>
<result property="createTime" column="create_time"/> <result property="createTime" column="create_time"/>
<result property="createBy" column="create_by"/> <result property="createBy" column="create_by"/>
<result property="createByName" column="create_by_name"/>
<result property="costTime" column="cost_time"/> <result property="costTime" column="cost_time"/>
<result property="remark" column="remark"/> <result property="remark" column="remark"/>
</resultMap> </resultMap>
@ -36,13 +37,28 @@
</sql> </sql>
<select id="selectSysMailLogList" parameterType="com.ruoyi.system.domain.SysMailLog" resultMap="SysMailLogResult"> <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> <where>
<if test="status != null ">and sys_mail_log.status = #{status}</if> <if test="status != null ">and t.status = #{status}</if>
<if test="to != null and to != ''">and sys_mail_log.to = #{to}</if> <if test="to != null and to != ''">and t.to = #{to}</if>
<if test="subject != null and subject != ''">and sys_mail_log.subject = #{subject}</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 != ''"> <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> </if>
</where> </where>
</select> </select>

@ -1,35 +1,38 @@
import request from '@/utils/request' import request, { upload } from '@/utils/request'
// 查询邮件发送日志列表 // 查询邮件发送日志列表
export function listMailLog(query) { export function listMailLog(query) {
return request({ return request({
url: '/system/mailLog/list', url: '/system/mailLog/list',
method: 'get', method: 'get',
params: query params: query
}) })
} }
// 查询邮件发送日志详细 // 查询邮件发送日志详细
export function getMailLog(mailLogId) { export function getMailLog(mailLogId) {
return request({ return request({
url: '/system/mailLog/' + mailLogId, url: '/system/mailLog/' + mailLogId,
method: 'get' method: 'get'
}) })
}
// TODO 临时邮件发送
export function sendTemporality(data) {
return request({
url: '/system/mailLog/sendTemporality',
method: 'post',
data: data
})
} }
// 删除邮件发送日志 // 删除邮件发送日志
export function delMailLog(mailLogId) { export function delMailLog(mailLogId) {
return request({ return request({
url: '/system/mailLog/' + mailLogId, url: '/system/mailLog/' + mailLogId,
method: 'delete' 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 emit = defineEmits();
const props = defineProps({ const props = defineProps({
//
limit: {
type: Number,
default: 5,
},
// //
fileSize: { fileSize: {
type: String, type: String,
@ -102,16 +97,6 @@ const props = defineProps({
}, },
}); });
defineExpose({
pond,
getFiles,
getFile,
addFile,
addFiles,
removeFile,
removeFiles,
});
// //
function handleInit() { function handleInit() {
// console.info('pond.value', pond.value) // console.info('pond.value', pond.value)
@ -157,6 +142,15 @@ function removeFiles() {
pond.value.removeFiles(); pond.value.removeFiles();
} }
defineExpose({
getFiles,
getFile,
addFile,
addFiles,
removeFile,
removeFiles,
});
</script> </script>
<!-- <!--

@ -4,37 +4,37 @@
<el-form-item label="发送状态" prop="status"> <el-form-item label="发送状态" prop="status">
<el-select v-model="queryParams.status" placeholder="请选择发送状态" clearable> <el-select v-model="queryParams.status" placeholder="请选择发送状态" clearable>
<el-option <el-option
v-for="dict in sys_mail_status" v-for="dict in sys_mail_status"
:key="dict.value" :key="dict.value"
:label="dict.label" :label="dict.label"
:value="dict.value" :value="dict.value"
/> />
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item label="收件人" prop="to"> <el-form-item label="收件人" prop="to">
<el-input <el-input
v-model="queryParams.to" v-model="queryParams.to"
placeholder="请输入收件人" placeholder="请输入收件人"
clearable clearable
@keyup.enter="handleQuery" @keyup.enter="handleQuery"
/> />
</el-form-item> </el-form-item>
<el-form-item label="邮件主题" prop="subject"> <el-form-item label="邮件主题" prop="subject">
<el-input <el-input
v-model="queryParams.subject" v-model="queryParams.subject"
placeholder="请输入邮件主题" placeholder="请输入邮件主题"
clearable clearable
@keyup.enter="handleQuery" @keyup.enter="handleQuery"
/> />
</el-form-item> </el-form-item>
<el-form-item label="发送时间" style="width: 308px"> <el-form-item label="发送时间" style="width: 308px">
<el-date-picker <el-date-picker
v-model="daterangeCreateTime" v-model="daterangeCreateTime"
value-format="YYYY-MM-DD" value-format="YYYY-MM-DD"
type="daterange" type="daterange"
range-separator="-" range-separator="-"
start-placeholder="开始日期" start-placeholder="开始日期"
end-placeholder="结束日期" end-placeholder="结束日期"
></el-date-picker> ></el-date-picker>
</el-form-item> </el-form-item>
</el-form> </el-form>
@ -48,69 +48,95 @@
</el-col> </el-col>
<el-col :span="1.5"> <el-col :span="1.5">
<el-button <el-button
type="primary" type="primary"
plain plain
icon="Plus" icon="Plus"
@click="handleSend" @click="handleSend"
v-hasPermi="['system:mailLog:send']" v-hasPermi="['system:mailLog:send']"
>临时邮件发送</el-button> >临时邮件发送
</el-button>
</el-col> </el-col>
<el-col :span="1.5"> <el-col :span="1.5">
<el-button <el-button
type="danger" type="danger"
plain plain
icon="Delete" icon="Delete"
:disabled="multiple" :disabled="multiple"
@click="handleDelete" @click="handleDelete"
v-hasPermi="['system:mailLog:remove']" v-hasPermi="['system:mailLog:remove']"
>删除</el-button> >删除
</el-button>
</el-col> </el-col>
<el-col :span="1.5"> <el-col :span="1.5">
<el-button <el-button
type="warning" type="warning"
plain plain
icon="Download" icon="Download"
@click="handleExport" @click="handleExport"
v-hasPermi="['system:mailLog:export']" v-hasPermi="['system:mailLog:export']"
>导出</el-button> >导出
</el-button>
</el-col> </el-col>
<right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar> <right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
</el-row> </el-row>
<el-table v-loading="loading" :data="mailLogList" @selection-change="handleSelectionChange" :show-overflow-tooltip="true"> <el-table v-loading="loading" :data="mailLogList" @selection-change="handleSelectionChange"
<el-table-column type="selection" width="30" align="center" /> :show-overflow-tooltip="true">
<el-table-column label="日志主键" align="center" prop="mailLogId" /> <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"> <el-table-column label="发送状态" align="center" prop="status">
<template #default="scope"> <template #default="scope">
<dict-tag :options="sys_mail_status" :value="scope.row.status"/> <dict-tag :options="sys_mail_status" :value="scope.row.status"/>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="自定业务类型" align="center" prop="businessType" /> <el-table-column label="自定业务类型" align="center" prop="businessType"/>
<el-table-column label="发件人" align="center" prop="from" /> <el-table-column label="发件人" align="center" prop="from"/>
<el-table-column label="收件人" align="center" prop="to" /> <el-table-column label="收件人" align="center" prop="to"/>
<el-table-column label="抄送" align="center" prop="cc" /> <el-table-column label="抄送" align="center" prop="cc"/>
<el-table-column label="邮件主题" align="center" prop="subject" /> <el-table-column label="邮件主题" align="center" prop="subject"/>
<el-table-column label="日志消息" align="center" prop="msg" /> <el-table-column label="日志消息" align="center" prop="msg"/>
<el-table-column label="发送时间" align="center" prop="createTime" width="180"> <el-table-column label="发送时间" align="center" prop="createTime" width="180">
<template #default="scope"> <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> </template>
</el-table-column> </el-table-column>
<el-table-column label="操作用户" align="center" prop="createBy" /> <el-table-column label="操作用户" align="center" prop="createByName"/>
<el-table-column label="消耗时间(ms)" align="center" prop="costTime" /> <el-table-column label="消耗时间(ms)" align="center" prop="costTime"/>
</el-table> </el-table>
<pagination <pagination
v-show="total>0" v-show="total>0"
:total="total" :total="total"
v-model:page="queryParams.pageNum" v-model:page="queryParams.pageNum"
v-model:limit="queryParams.pageSize" v-model:limit="queryParams.pageSize"
@pagination="getList" @pagination="getList"
/> />
<!-- TODO 临时邮件发送对话框 --> <!-- 临时邮件发送对话框 -->
<el-dialog :title="title" v-model="open" width="500px" append-to-body> <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 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> </el-form>
<template #footer> <template #footer>
<div class="dialog-footer"> <div class="dialog-footer">
@ -123,10 +149,10 @@
</template> </template>
<script setup name="MailLog"> <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 {proxy} = getCurrentInstance();
const { sys_mail_status } = proxy.useDict('sys_mail_status'); const {sys_mail_status} = proxy.useDict('sys_mail_status');
const mailLogList = ref([]); const mailLogList = ref([]);
const open = ref(false); const open = ref(false);
@ -138,6 +164,12 @@ const multiple = ref(true);
const total = ref(0); const total = ref(0);
const title = ref(""); const title = ref("");
const daterangeCreateTime = ref([]); const daterangeCreateTime = ref([]);
const senderAccount = ref({
host: null,
port: null,
username: null,
});
const fileUploadRef = ref(null);
const data = reactive({ const data = reactive({
form: {}, form: {},
@ -150,13 +182,19 @@ const data = reactive({
createTime: null, createTime: null,
}, },
rules: { rules: {
status: [ from: [
{ required: true, message: "发送状态不能为空", trigger: "change" }, {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() { function getList() {
@ -189,12 +227,12 @@ function reset() {
to: null, to: null,
cc: null, cc: null,
subject: null, subject: null,
msg: null, content: null,
createTime: null, attachmentsId: null,
createBy: null,
costTime: null,
remark: null
}; };
if (fileUploadRef.value) {
fileUploadRef.value.removeFiles();
}
proxy.resetForm("mailLogRef"); proxy.resetForm("mailLogRef");
} }
@ -218,18 +256,34 @@ function handleSelectionChange(selection) {
multiple.value = !selection.length; multiple.value = !selection.length;
} }
/** 新增按钮操作 */ /** 临时邮件发送按钮操作 */
function handleSend() { function handleSend() {
reset(); reset();
open.value = true; open.value = true;
title.value = "临时邮件发送"; title.value = "临时邮件发送";
form.value.from = senderAccount.value.username;
} }
/** 提交按钮 */ /** 提交按钮 */
function submitForm() { function submitForm() {
proxy.$refs["mailLogRef"].validate(valid => { proxy.$refs["mailLogRef"].validate(valid => {
if (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) { function handleDelete(row) {
const _mailLogIds = row.mailLogId || ids.value; const _mailLogIds = row.mailLogId || ids.value;
proxy.$modal.confirm('是否确认删除邮件发送日志编号为"' + _mailLogIds + '"的数据项?').then(function() { proxy.$modal.confirm('是否确认删除邮件发送日志编号为"' + _mailLogIds + '"的数据项?').then(function () {
return delMailLog(_mailLogIds); return delMailLog(_mailLogIds);
}).then(() => { }).then(() => {
getList(); getList();
proxy.$modal.msgSuccess("删除成功"); proxy.$modal.msgSuccess("删除成功");
}).catch(() => {}); }).catch(() => {
});
} }
/** 导出按钮操作 */ /** 导出按钮操作 */
@ -252,6 +307,16 @@ function handleExport() {
}, `mailLog_${new Date().getTime()}.xlsx`) }, `mailLog_${new Date().getTime()}.xlsx`)
} }
// /** 获取发件人账号 */
function getMailSenderAccount() {
getMailSenderInfo().then(response => {
senderAccount.value = response.data;
});
}
//
getMailSenderAccount();
//
//getList(); //getList();
</script> </script>

@ -108,7 +108,6 @@
<script setup name="InvTransHis"> <script setup name="InvTransHis">
import { listInvTransHis } from "@/api/wms/InvTransHis"; import { listInvTransHis } from "@/api/wms/InvTransHis";
import { listWarehouseInfo } from "@/api/wms/WarehouseInfo"; import { listWarehouseInfo } from "@/api/wms/WarehouseInfo";
import DataSelect from "@/components/DataSelect/index.vue";
const { proxy } = getCurrentInstance(); const { proxy } = getCurrentInstance();
const {wms_inv_trans_type} = proxy.useDict("wms_inv_trans_type"); const {wms_inv_trans_type} = proxy.useDict("wms_inv_trans_type");

@ -549,6 +549,9 @@ function reset() {
remark4: null, remark4: null,
remark5: null, remark5: null,
}; };
if (fileUpload.value) {
fileUpload.value.removeFiles();
}
proxy.resetForm("ItemInfoRef"); proxy.resetForm("ItemInfoRef");
} }

@ -11,7 +11,7 @@
Target Server Version : 80200 (8.2.0) Target Server Version : 80200 (8.2.0)
File Encoding : 65001 File Encoding : 65001
Date: 01/03/2024 14:30:57 Date: 04/03/2024 16:13:20
*/ */
SET NAMES utf8mb4; SET NAMES utf8mb4;
@ -572,7 +572,7 @@ CREATE TABLE `sys_config` (
`update_time` datetime NULL DEFAULT NULL COMMENT '更新时间', `update_time` datetime NULL DEFAULT NULL COMMENT '更新时间',
`remark` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '备注', `remark` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '备注',
PRIMARY KEY (`config_id`) USING BTREE 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 -- 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 (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 (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 (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 (101, '邮件-SMTP服务器端口', 'sys.mail.smtpPort', '587', '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 (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 (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 -- Table structure for sys_dept
@ -833,7 +834,7 @@ CREATE TABLE `sys_logininfor` (
PRIMARY KEY (`info_id`) USING BTREE, PRIMARY KEY (`info_id`) USING BTREE,
INDEX `idx_sys_logininfor_s`(`status` ASC) USING BTREE, INDEX `idx_sys_logininfor_s`(`status` ASC) USING BTREE,
INDEX `idx_sys_logininfor_lt`(`access_time` 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 -- 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 '收件人', `to` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT '' COMMENT '收件人',
`cc` 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 '邮件主题', `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_time` datetime NULL DEFAULT NULL COMMENT '发送时间',
`create_by` bigint NULL DEFAULT 0 COMMENT '操作用户', `create_by` bigint NULL DEFAULT 0 COMMENT '操作用户',
`cost_time` bigint NULL DEFAULT NULL COMMENT '消耗时间(ms)', `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_bt`(`business_type` ASC) USING BTREE,
INDEX `idx_sys_oper_log_s`(`status` ASC) USING BTREE, INDEX `idx_sys_oper_log_s`(`status` ASC) USING BTREE,
INDEX `idx_sys_oper_log_ot`(`oper_time` 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 -- 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 -- Table structure for sys_post

Loading…
Cancel
Save