新增邮件发送记录编辑接口,邮件记录重新发送接口
This commit is contained in:
+107
@@ -0,0 +1,107 @@
|
||||
package com.ruoyi.system.domain.entity.shortmessage;
|
||||
|
||||
import java.util.Date;
|
||||
import javax.persistence.*;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@Table(name = "ms_send_mail_history_record")
|
||||
public class MsSendMailHistoryRecord {
|
||||
@Id
|
||||
@GeneratedValue(generator = "JDBC")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 邮件名称
|
||||
*/
|
||||
@Column(name = "mail_name")
|
||||
private String mailName;
|
||||
|
||||
/**
|
||||
* 邮件接收地址
|
||||
*/
|
||||
@Column(name = "mail_address")
|
||||
private String mailAddress;
|
||||
|
||||
/**
|
||||
* 发送时间
|
||||
*/
|
||||
@Column(name = "send_time")
|
||||
private Date sendTime;
|
||||
|
||||
/**
|
||||
* 案件编号
|
||||
*/
|
||||
@Column(name = "case_num")
|
||||
private String caseNum;
|
||||
|
||||
/**
|
||||
* 发送状态
|
||||
*/
|
||||
@Column(name = "send_status")
|
||||
private Long sendStatus;
|
||||
|
||||
/**
|
||||
* 立案申请id
|
||||
*/
|
||||
@Column(name = "case_id")
|
||||
private Long caseId;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@Column(name = "create_time")
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 创建者
|
||||
*/
|
||||
@Column(name = "create_by")
|
||||
private String createBy;
|
||||
|
||||
/**
|
||||
* 更新者
|
||||
*/
|
||||
@Column(name = "update_by")
|
||||
private String updateBy;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@Column(name = "update_time")
|
||||
private Date updateTime;
|
||||
|
||||
/**
|
||||
* 附件id用英文逗号隔开
|
||||
*/
|
||||
@Column(name = "file_ids")
|
||||
private String fileIds;
|
||||
|
||||
/**
|
||||
* 邮件主题
|
||||
*/
|
||||
@Column(name = "mail_subject")
|
||||
private String mailSubject;
|
||||
|
||||
/**
|
||||
* 邮件发送地址
|
||||
*/
|
||||
@Column(name = "mail_from_address")
|
||||
private String mailFromAddress;
|
||||
|
||||
/**
|
||||
* 邮件父类id
|
||||
*/
|
||||
@Column(name = "parent_id")
|
||||
private Long parentId;
|
||||
|
||||
/**
|
||||
* 邮件内容
|
||||
*/
|
||||
@Column(name = "mail_content")
|
||||
private String mailContent;
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
package com.ruoyi.system.mapper.shortmessage;
|
||||
|
||||
import com.ruoyi.system.domain.entity.shortmessage.MsSendMailHistoryRecord;
|
||||
import tk.mybatis.mapper.common.Mapper;
|
||||
|
||||
public interface MsSendMailHistoryRecordMapper extends Mapper<MsSendMailHistoryRecord> {
|
||||
}
|
||||
+11
-1
@@ -3,9 +3,10 @@ package com.ruoyi.wisdomarbitrate.domain.dto.sendrecord;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.ruoyi.common.annotation.Excel;
|
||||
import com.ruoyi.common.core.domain.BaseEntity;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
public class SendMailRecord extends BaseEntity {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@@ -40,6 +41,15 @@ public class SendMailRecord extends BaseEntity {
|
||||
private Integer sendStatus;
|
||||
|
||||
|
||||
/** 附件id */
|
||||
private String fileIds;
|
||||
|
||||
/** 邮件主题 */
|
||||
private String mailSubject;
|
||||
|
||||
/** 邮件发件人地址 */
|
||||
private String mailFromAddress;
|
||||
|
||||
|
||||
public Integer getSendStatus() {
|
||||
return sendStatus;
|
||||
|
||||
+25
-3
@@ -5,10 +5,32 @@ import com.ruoyi.wisdomarbitrate.domain.dto.sendrecord.SendMailRecord;
|
||||
import java.util.List;
|
||||
|
||||
public interface SendMailRecordMapper {
|
||||
/**
|
||||
* 新增发送邮件记录
|
||||
*
|
||||
* @param sendMailRecord 发送邮件记录
|
||||
* @return 结果
|
||||
*/
|
||||
|
||||
int saveSendMailRecord(SendMailRecord sendMailRecord);
|
||||
|
||||
/**
|
||||
* 查询发送邮件记录
|
||||
*
|
||||
* @param sendMailRecord 发送邮件记录
|
||||
* @return 结果
|
||||
*/
|
||||
List<SendMailRecord> selectSendMailRecord(SendMailRecord sendMailRecord);
|
||||
/**
|
||||
* 修改发送邮件记录
|
||||
*
|
||||
* @param sendMailRecord 发送邮件记录
|
||||
* @return 结果
|
||||
*/
|
||||
int updateSendMailRecord(SendMailRecord sendMailRecord);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 根据id查询发送邮件记录
|
||||
* @param id
|
||||
*/
|
||||
SendMailRecord querySendMailRecordById(Long id);
|
||||
}
|
||||
|
||||
+20
-3
@@ -1,15 +1,32 @@
|
||||
package com.ruoyi.wisdomarbitrate.service.sendrecord;
|
||||
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.wisdomarbitrate.domain.dto.sendrecord.SendMailRecord;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface ISendMailRecordService {
|
||||
|
||||
/**
|
||||
* 查询邮件发送记录
|
||||
*
|
||||
* @param sendMailRecord
|
||||
* @return
|
||||
*/
|
||||
|
||||
List<SendMailRecord> selectSendMailRecordList(SendMailRecord sendMailRecord);
|
||||
|
||||
/**
|
||||
* 编辑邮件记录
|
||||
*
|
||||
* @param sendMailRecord
|
||||
*/
|
||||
AjaxResult updateSendMailRecord(SendMailRecord sendMailRecord);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 重新发送邮件
|
||||
*
|
||||
* @param sendMailRecord
|
||||
* @return
|
||||
*/
|
||||
Boolean reSendMailRecord(SendMailRecord sendMailRecord);
|
||||
}
|
||||
|
||||
+79
@@ -1,11 +1,19 @@
|
||||
package com.ruoyi.wisdomarbitrate.service.sendrecord.impl;
|
||||
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.utils.EmailOutUtil;
|
||||
import com.ruoyi.system.domain.entity.shortmessage.MsSendMailHistoryRecord;
|
||||
import com.ruoyi.system.mapper.shortmessage.MsSendMailHistoryRecordMapper;
|
||||
import com.ruoyi.wisdomarbitrate.domain.dto.sendrecord.SendMailRecord;
|
||||
import com.ruoyi.wisdomarbitrate.domain.entity.mscase.MsCaseAttach;
|
||||
import com.ruoyi.wisdomarbitrate.mapper.mscase.MsCaseAttachMapper;
|
||||
import com.ruoyi.wisdomarbitrate.mapper.sendrecord.SendMailRecordMapper;
|
||||
import com.ruoyi.wisdomarbitrate.service.sendrecord.ISendMailRecordService;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
@@ -20,6 +28,77 @@ public class SendMailRecordServiceImpl implements ISendMailRecordService {
|
||||
return records;
|
||||
}
|
||||
|
||||
@Autowired
|
||||
MsSendMailHistoryRecordMapper msSendMailHistoryRecordMapper;
|
||||
|
||||
/**
|
||||
* 编辑邮件记录
|
||||
*
|
||||
* @param sendMailRecord
|
||||
*/
|
||||
@Override
|
||||
public AjaxResult updateSendMailRecord(SendMailRecord sendMailRecord) {
|
||||
try {
|
||||
if (sendMailRecord != null && sendMailRecord.getId() != null) {
|
||||
SendMailRecord old = sendMailRecordMapper.querySendMailRecordById(sendMailRecord.getId());
|
||||
MsSendMailHistoryRecord msSendMailHistoryRecord = new MsSendMailHistoryRecord();
|
||||
BeanUtils.copyProperties(old, msSendMailHistoryRecord);
|
||||
msSendMailHistoryRecord.setParentId(old.getId());
|
||||
msSendMailHistoryRecord.setId(null);
|
||||
msSendMailHistoryRecordMapper.insertSelective(msSendMailHistoryRecord);
|
||||
sendMailRecordMapper.updateSendMailRecord(sendMailRecord);
|
||||
return AjaxResult.success("编辑成功");
|
||||
} else {
|
||||
return AjaxResult.error("编辑失败");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return AjaxResult.error("编辑失败");
|
||||
}
|
||||
}
|
||||
|
||||
@Autowired
|
||||
private EmailOutUtil emailOutUtil;
|
||||
@Autowired
|
||||
MsCaseAttachMapper msCaseAttachMapper;
|
||||
|
||||
/**
|
||||
* 重新发送邮件
|
||||
*
|
||||
* @param sendMailRecord
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Boolean reSendMailRecord(SendMailRecord sendMailRecord) {
|
||||
List<File> fileList = null;
|
||||
if (sendMailRecord.getFileIds() != null && sendMailRecord.getFileIds() != "") {
|
||||
String[] fileIds = sendMailRecord.getFileIds().split(",");
|
||||
for (int i = 0; i < fileIds.length; i++) {
|
||||
String fileId = fileIds[i];
|
||||
try {
|
||||
Long id = Long.parseLong(fileId);
|
||||
MsCaseAttach msCaseAttach = msCaseAttachMapper.queryAnnexById(id);
|
||||
String annexPath = msCaseAttach.getAnnexPath();
|
||||
if (annexPath != null && annexPath != "") {
|
||||
String prefix = "/profile";
|
||||
int startIndex = prefix.length();
|
||||
String path = "/home/ruoyi/uploadPath/" + annexPath.substring(startIndex + 1);
|
||||
File file = new File(path);
|
||||
fileList.add(file);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
Boolean flag = emailOutUtil.sendEmil(sendMailRecord.getMailAddress(), sendMailRecord.getMailContent(), sendMailRecord.getMailSubject(), fileList, null);
|
||||
//发送成功后更细邮件记录的发送时间和发送状态
|
||||
if (flag) {
|
||||
sendMailRecord.setSendStatus(1);
|
||||
sendMailRecord.setSendTime(new java.util.Date());
|
||||
sendMailRecord.setUpdateTime(new java.util.Date());
|
||||
sendMailRecordMapper.updateSendMailRecord(sendMailRecord);
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user