新增邮件发送记录编辑接口,邮件记录重新发送接口 #140

Merged
bgy merged 1 commits from bgy into dev 2024-04-17 07:25:39 +00:00
10 changed files with 376 additions and 68 deletions
@@ -1,13 +1,12 @@
package com.ruoyi.web.controller.wisdomarbitrate.sendrecord;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.wisdomarbitrate.domain.dto.sendrecord.SendMailRecord;
import com.ruoyi.wisdomarbitrate.service.sendrecord.ISendMailRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@@ -21,13 +20,30 @@ public class SendMailRecordController extends BaseController {
* 查询发送邮件记录列表
*/
@GetMapping("/list")
public TableDataInfo list(SendMailRecord sendMailRecord)
{
public TableDataInfo list(SendMailRecord sendMailRecord) {
startPage();
List<SendMailRecord> list = sendMailRecordService.selectSendMailRecordList(sendMailRecord);
return getDataTable(list);
}
/**
* 编辑邮件记录
*/
@PostMapping("/update")
public AjaxResult update(@RequestBody SendMailRecord sendMailRecord) {
return sendMailRecordService.updateSendMailRecord(sendMailRecord);
}
/**
* 重新发送邮件记录
*/
@PostMapping("/reSendMailRecord")
public AjaxResult reSendMailRecord(@RequestBody SendMailRecord sendMailRecord) {
Boolean aBoolean = sendMailRecordService.reSendMailRecord(sendMailRecord);
if (aBoolean) {
return AjaxResult.success("发送成功");
} else {
return AjaxResult.error("发送失败");
}
}
}
@@ -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;
}
@@ -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> {
}
@@ -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;
@@ -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);
}
@@ -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);
}
@@ -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;
}
}
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.system.mapper.shortmessage.MsSendMailHistoryRecordMapper">
<resultMap id="BaseResultMap" type="com.ruoyi.system.domain.entity.shortmessage.MsSendMailHistoryRecord">
<!--
WARNING - @mbg.generated
-->
<id column="id" jdbcType="BIGINT" property="id" />
<result column="mail_name" jdbcType="VARCHAR" property="mailName" />
<result column="mail_address" jdbcType="VARCHAR" property="mailAddress" />
<result column="send_time" jdbcType="TIMESTAMP" property="sendTime" />
<result column="case_num" jdbcType="VARCHAR" property="caseNum" />
<result column="send_status" jdbcType="BIGINT" property="sendStatus" />
<result column="case_id" jdbcType="BIGINT" property="caseId" />
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
<result column="create_by" jdbcType="VARCHAR" property="createBy" />
<result column="update_by" jdbcType="VARCHAR" property="updateBy" />
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
<result column="file_ids" jdbcType="VARCHAR" property="fileIds" />
<result column="mail_subject" jdbcType="VARCHAR" property="mailSubject" />
<result column="mail_from_address" jdbcType="VARCHAR" property="mailFromAddress" />
<result column="parent_id" jdbcType="BIGINT" property="parentId" />
<result column="mail_content" jdbcType="LONGVARCHAR" property="mailContent" />
</resultMap>
</mapper>
@@ -5,20 +5,24 @@
<mapper namespace="com.ruoyi.wisdomarbitrate.mapper.sendrecord.SendMailRecordMapper">
<resultMap type="com.ruoyi.wisdomarbitrate.domain.dto.sendrecord.SendMailRecord" id="SendMailRecordResult">
<id property="id" column="id" />
<result property="mailName" column="mail_name" />
<result property="mailContent" column="mail_content" />
<result property="mailAddress" column="mail_address" />
<result property="sendTime" column="send_time" />
<result property="caseId" column="case_id" />
<result property="caseNum" column="case_num" />
<result property="sendStatus" column="send_status" />
<id property="id" column="id"/>
<result property="mailName" column="mail_name"/>
<result property="mailContent" column="mail_content"/>
<result property="mailAddress" column="mail_address"/>
<result property="sendTime" column="send_time"/>
<result property="caseId" column="case_id"/>
<result property="caseNum" column="case_num"/>
<result property="sendStatus" column="send_status"/>
<result property="fileIds" column="file_ids"/>
<result property="mailSubject" column="mail_subject"/>
<result property="mailFromAddress" column="mail_from_address"/>
</resultMap>
<select id="selectSendMailRecord" parameterType="com.ruoyi.wisdomarbitrate.domain.dto.sendrecord.SendMailRecord" resultMap="SendMailRecordResult">
<select id="selectSendMailRecord" parameterType="com.ruoyi.wisdomarbitrate.domain.dto.sendrecord.SendMailRecord"
resultMap="SendMailRecordResult">
SELECT s.id ,s.mail_name ,s.mail_content ,s.mail_address ,s.send_time ,s.case_id ,s.create_time ,s.create_by ,
s.update_by ,s.update_time , s.send_status ,c.case_num
s.update_by ,s.update_time , s.send_status ,s.file_ids ,s.mail_subject ,s.mail_from_address ,c.case_num
from ms_send_mail_record s left join ms_case_application c
on s.case_id = c.id
<where>
@@ -38,6 +42,9 @@
<if test="caseId != null ">case_id,</if>
<if test="sendStatus != null ">send_status,</if>
<if test="createBy != null and createBy != ''">create_by,</if>
<if test="fileIds != null and fileIds != ''">file_ids,</if>
<if test="mailSubject != null and mailSubject != ''">mail_subject,</if>
<if test="mailFromAddress != null and mailFromAddress != ''">mail_from_address,</if>
create_time
)values(
<if test="mailName != null and mailName != ''">#{mailName},</if>
@@ -47,15 +54,23 @@
<if test="caseId != null ">#{caseId},</if>
<if test="sendStatus != null ">#{sendStatus},</if>
<if test="createBy != null and createBy != ''">#{createBy},</if>
<if test="fileIds != null and fileIds != ''">#{fileIds},</if>
<if test="mailSubject != null and mailSubject != ''">#{mailSubject},</if>
<if test="mailFromAddress != null and mailFromAddress != ''">#{mailFromAddress},</if>
sysdate()
)
</insert>
<update id="updateSendMailRecord">
update ms_send_mail_record
set mail_content= #{mailContent},
update_time=#{updateTime},
send_time=#{sendTime},
send_status=#{sendStatus}
where id = #{id}
</update>
<select id="querySendMailRecordById" resultMap="SendMailRecordResult">
select *
from ms_send_mail_record
where id = #{id}
</select>
</mapper>
@@ -5,20 +5,21 @@
<mapper namespace="com.ruoyi.wisdomarbitrate.mapper.sendrecord.SmsRecordMapper">
<resultMap type="com.ruoyi.wisdomarbitrate.domain.dto.sendrecord.SmsSendRecord" id="SmsSendRecordResult">
<id property="id" column="id" />
<result property="caseId" column="case_appli_id" />
<result property="caseNum" column="case_num" />
<result property="phone" column="phone" />
<result property="sendTime" column="send_time" />
<result property="sendContent" column="send_content" />
<result property="createTime" column="create_time" />
<result property="updateTime" column="update_time" />
<result property="createBy" column="create_by" />
<result property="updateBy" column="update_by" />
<result property="sendStatus" column="send_status" />
<result property="sid" column="sid" />
<id property="id" column="id"/>
<result property="caseId" column="case_appli_id"/>
<result property="caseNum" column="case_num"/>
<result property="phone" column="phone"/>
<result property="sendTime" column="send_time"/>
<result property="sendContent" column="send_content"/>
<result property="createTime" column="create_time"/>
<result property="updateTime" column="update_time"/>
<result property="createBy" column="create_by"/>
<result property="updateBy" column="update_by"/>
<result property="sendStatus" column="send_status"/>
<result property="sid" column="sid"/>
</resultMap>
<insert id="saveSmsSendRecord" parameterType="com.ruoyi.wisdomarbitrate.domain.dto.sendrecord.SmsSendRecord" useGeneratedKeys="true" keyProperty="id">
<insert id="saveSmsSendRecord" parameterType="com.ruoyi.wisdomarbitrate.domain.dto.sendrecord.SmsSendRecord"
useGeneratedKeys="true" keyProperty="id">
insert into ms_sms_send_record(
<if test="caseId != null ">case_appli_id,</if>
@@ -71,7 +72,8 @@
</foreach>
</insert>
<select id="getSmsSendRecord" parameterType="com.ruoyi.wisdomarbitrate.domain.dto.sendrecord.SmsSendRecord" resultMap="SmsSendRecordResult">
<select id="getSmsSendRecord" parameterType="com.ruoyi.wisdomarbitrate.domain.dto.sendrecord.SmsSendRecord"
resultMap="SmsSendRecordResult">
select *
from ms_sms_send_record
@@ -84,20 +86,28 @@
</select>
<select id="selectBySId" resultMap="SmsSendRecordResult">
select * from ms_sms_send_record where sid=#{sid}
select *
from ms_sms_send_record
where sid = #{sid}
</select>
<update id="updateStatus">
update ms_sms_send_record
set send_status= #{sendStatus} ,reason=#{reason} where sid=#{sid}
set send_status= #{sendStatus},
reason=#{reason}
where sid = #{sid}
</update>
<update id="updateSendContent">
update ms_sms_send_record
set send_content= #{sendContent} ,update_time=#{updateTime} where id=#{id}
set send_content= #{sendContent},
update_time=#{updateTime}
where id = #{id}
</update>
<select id="selectById" resultMap="SmsSendRecordResult">
select * from ms_sms_send_record where id=#{id}
select *
from ms_sms_send_record
where id = #{id}
</select>
</mapper>