新增短信编辑和重新发送短信接口
This commit is contained in:
+49
@@ -0,0 +1,49 @@
|
|||||||
|
package com.ruoyi.web.controller.wisdomarbitrate.sendrecord;
|
||||||
|
|
||||||
|
import com.ruoyi.common.annotation.Anonymous;
|
||||||
|
import com.ruoyi.common.core.domain.AjaxResult;
|
||||||
|
import com.ruoyi.wisdomarbitrate.domain.dto.sendrecord.SmsSendRecord;
|
||||||
|
import com.ruoyi.wisdomarbitrate.mapper.sendrecord.SmsRecordMapper;
|
||||||
|
import com.ruoyi.wisdomarbitrate.service.sendrecord.ShortMessageService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/shortMessage")
|
||||||
|
public class ShortMessageController {
|
||||||
|
@Autowired
|
||||||
|
private SmsRecordMapper smsRecordMapper;
|
||||||
|
@Autowired
|
||||||
|
private ShortMessageService shortMessageService;
|
||||||
|
|
||||||
|
@Anonymous
|
||||||
|
@PostMapping("/updateSendContent")
|
||||||
|
public AjaxResult update(@RequestBody SmsSendRecord smsSendRecord) {
|
||||||
|
if (smsSendRecord != null && smsSendRecord.getId() != null) {
|
||||||
|
SmsSendRecord oldSendRecord = smsRecordMapper.selectById(smsSendRecord.getId());
|
||||||
|
smsSendRecord.setUpdateTime(new Date());
|
||||||
|
smsRecordMapper.updateSendContent(smsSendRecord);
|
||||||
|
shortMessageService.insertShortMessageHistoryRecord(oldSendRecord);
|
||||||
|
return AjaxResult.success();
|
||||||
|
}
|
||||||
|
return AjaxResult.error("更新失败");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 重新发送短信
|
||||||
|
*/
|
||||||
|
@Anonymous
|
||||||
|
@PostMapping("/reSendShortMessage")
|
||||||
|
public AjaxResult reSendShortMessage(@RequestBody SmsSendRecord smsSendRecord) {
|
||||||
|
if (smsSendRecord != null) {
|
||||||
|
AjaxResult result = shortMessageService.reSendShortMessage(smsSendRecord);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
return AjaxResult.error("发送失败");
|
||||||
|
}
|
||||||
|
}
|
||||||
+92
@@ -0,0 +1,92 @@
|
|||||||
|
package com.ruoyi.system.domain.entity.shortmessage;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
import javax.persistence.*;
|
||||||
|
|
||||||
|
import lombok.*;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
@Builder
|
||||||
|
@Table(name = "ms_sms_send_history_record")
|
||||||
|
public class MsSmsSendHistoryRecord {
|
||||||
|
@Id
|
||||||
|
@GeneratedValue(generator = "JDBC")
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 案件id
|
||||||
|
*/
|
||||||
|
@Column(name = "case_appli_id")
|
||||||
|
private Long caseAppliId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 案件编号
|
||||||
|
*/
|
||||||
|
@Column(name = "case_num")
|
||||||
|
private String caseNum;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 手机号
|
||||||
|
*/
|
||||||
|
private String phone;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 发送时间
|
||||||
|
*/
|
||||||
|
@Column(name = "send_time")
|
||||||
|
private Date sendTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 发送状态,0-失败,1-成功
|
||||||
|
*/
|
||||||
|
@Column(name = "send_status")
|
||||||
|
private Long sendStatus;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 发送内容
|
||||||
|
*/
|
||||||
|
@Column(name = "send_content")
|
||||||
|
private String sendContent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建时间
|
||||||
|
*/
|
||||||
|
@Column(name = "create_time")
|
||||||
|
private Date createTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新时间
|
||||||
|
*/
|
||||||
|
@Column(name = "update_time")
|
||||||
|
private Date updateTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建人
|
||||||
|
*/
|
||||||
|
@Column(name = "create_by")
|
||||||
|
private String createBy;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新者
|
||||||
|
*/
|
||||||
|
@Column(name = "update_by")
|
||||||
|
private String updateBy;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 发送短信唯一标识
|
||||||
|
*/
|
||||||
|
private String sid;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 父类短信id
|
||||||
|
*/
|
||||||
|
@Column(name = "parent_id")
|
||||||
|
private Long parentId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 失败原因
|
||||||
|
*/
|
||||||
|
private String reason;
|
||||||
|
}
|
||||||
+7
@@ -0,0 +1,7 @@
|
|||||||
|
package com.ruoyi.system.mapper.shortmessage;
|
||||||
|
|
||||||
|
import com.ruoyi.system.domain.entity.shortmessage.MsSmsSendHistoryRecord;
|
||||||
|
import tk.mybatis.mapper.common.Mapper;
|
||||||
|
|
||||||
|
public interface MsSmsSendHistoryRecordMapper extends Mapper<MsSmsSendHistoryRecord> {
|
||||||
|
}
|
||||||
+11
@@ -21,4 +21,15 @@ public interface SmsRecordMapper {
|
|||||||
int batchSaveSmsSendRecord(@Param("list") List<SmsSendRecord> smsSendRecordList);
|
int batchSaveSmsSendRecord(@Param("list") List<SmsSendRecord> smsSendRecordList);
|
||||||
SmsSendRecord selectBySId(@Param("sid") String sid);
|
SmsSendRecord selectBySId(@Param("sid") String sid);
|
||||||
void updateStatus (SmsSendRecord smsSendRecord);
|
void updateStatus (SmsSendRecord smsSendRecord);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新短信发送内容
|
||||||
|
* @param smsSendRecord
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
int updateSendContent(SmsSendRecord smsSendRecord);
|
||||||
|
/**
|
||||||
|
* 通过id查询短信发送记录
|
||||||
|
*/
|
||||||
|
SmsSendRecord selectById(@Param("id") Long id);
|
||||||
}
|
}
|
||||||
|
|||||||
+19
@@ -0,0 +1,19 @@
|
|||||||
|
package com.ruoyi.wisdomarbitrate.service.sendrecord;
|
||||||
|
|
||||||
|
import com.ruoyi.common.core.domain.AjaxResult;
|
||||||
|
import com.ruoyi.system.domain.entity.shortmessage.MsSmsSendHistoryRecord;
|
||||||
|
import com.ruoyi.system.mapper.shortmessage.MsSmsSendHistoryRecordMapper;
|
||||||
|
import com.ruoyi.wisdomarbitrate.domain.dto.sendrecord.SmsSendRecord;
|
||||||
|
|
||||||
|
public interface ShortMessageService {
|
||||||
|
/**
|
||||||
|
* 新增发送历史记录
|
||||||
|
*/
|
||||||
|
void insertShortMessageHistoryRecord(SmsSendRecord smsSendRecord);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 重新发送短信
|
||||||
|
* @param smsSendRecord
|
||||||
|
*/
|
||||||
|
AjaxResult reSendShortMessage(SmsSendRecord smsSendRecord);
|
||||||
|
}
|
||||||
+54
@@ -0,0 +1,54 @@
|
|||||||
|
package com.ruoyi.wisdomarbitrate.service.sendrecord.impl;
|
||||||
|
|
||||||
|
import cn.hutool.json.JSONObject;
|
||||||
|
import com.ruoyi.common.core.domain.AjaxResult;
|
||||||
|
import com.ruoyi.common.enums.SMSStatusEnum;
|
||||||
|
import com.ruoyi.common.utils.SmsUtils;
|
||||||
|
import com.ruoyi.system.domain.entity.shortmessage.MsSmsSendHistoryRecord;
|
||||||
|
import com.ruoyi.system.mapper.shortmessage.MsSmsSendHistoryRecordMapper;
|
||||||
|
import com.ruoyi.wisdomarbitrate.domain.dto.sendrecord.SmsSendRecord;
|
||||||
|
import com.ruoyi.wisdomarbitrate.service.sendrecord.ShortMessageService;
|
||||||
|
import org.springframework.beans.BeanUtils;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class ShortMessageServiceImpl implements ShortMessageService {
|
||||||
|
@Autowired
|
||||||
|
MsSmsSendHistoryRecordMapper msSmsSendHistoryRecordMapper;
|
||||||
|
/**
|
||||||
|
* 新增发送历史记录
|
||||||
|
*
|
||||||
|
* @param smsSendRecord
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void insertShortMessageHistoryRecord(SmsSendRecord smsSendRecord) {
|
||||||
|
if(smsSendRecord!=null){
|
||||||
|
MsSmsSendHistoryRecord historyRecord=new MsSmsSendHistoryRecord();
|
||||||
|
BeanUtils.copyProperties(smsSendRecord,historyRecord);
|
||||||
|
historyRecord.setId(null);
|
||||||
|
historyRecord.setParentId(smsSendRecord.getId());
|
||||||
|
msSmsSendHistoryRecordMapper.insert(historyRecord);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 重新发送短信
|
||||||
|
*
|
||||||
|
* @param smsSendRecord
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public AjaxResult reSendShortMessage(SmsSendRecord smsSendRecord) {
|
||||||
|
SmsUtils.SendSmsRequest request = new SmsUtils.SendSmsRequest();
|
||||||
|
//TODO 模版id待替换
|
||||||
|
request.setTemplateId("1955047");
|
||||||
|
request.setPhone(smsSendRecord.getPhone());
|
||||||
|
request.setTemplateParamSet(new String[]{ smsSendRecord.getSendContent()});
|
||||||
|
JSONObject resultObj = SmsUtils.sendSms(request);
|
||||||
|
if(resultObj.get("status")!=null && !resultObj.get("status").equals(SMSStatusEnum.FAIL.getCode())){
|
||||||
|
return AjaxResult.success("短信发送成功");
|
||||||
|
}else {
|
||||||
|
return AjaxResult.warn("短信发送失败");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+23
@@ -0,0 +1,23 @@
|
|||||||
|
<?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.MsSmsSendHistoryRecordMapper">
|
||||||
|
<resultMap id="BaseResultMap" type="com.ruoyi.system.domain.entity.shortmessage.MsSmsSendHistoryRecord">
|
||||||
|
<!--
|
||||||
|
WARNING - @mbg.generated
|
||||||
|
-->
|
||||||
|
<id column="id" jdbcType="BIGINT" property="id" />
|
||||||
|
<result column="case_appli_id" jdbcType="BIGINT" property="caseAppliId" />
|
||||||
|
<result column="case_num" jdbcType="VARCHAR" property="caseNum" />
|
||||||
|
<result column="phone" jdbcType="VARCHAR" property="phone" />
|
||||||
|
<result column="send_time" jdbcType="TIMESTAMP" property="sendTime" />
|
||||||
|
<result column="send_status" jdbcType="BIGINT" property="sendStatus" />
|
||||||
|
<result column="send_content" jdbcType="VARCHAR" property="sendContent" />
|
||||||
|
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
|
||||||
|
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
|
||||||
|
<result column="create_by" jdbcType="VARCHAR" property="createBy" />
|
||||||
|
<result column="update_by" jdbcType="VARCHAR" property="updateBy" />
|
||||||
|
<result column="sid" jdbcType="VARCHAR" property="sid" />
|
||||||
|
<result column="parent_id" jdbcType="BIGINT" property="parentId" />
|
||||||
|
<result column="reason" jdbcType="LONGVARCHAR" property="reason" />
|
||||||
|
</resultMap>
|
||||||
|
</mapper>
|
||||||
@@ -91,5 +91,13 @@
|
|||||||
update ms_sms_send_record
|
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>
|
||||||
|
<update id="updateSendContent">
|
||||||
|
update ms_sms_send_record
|
||||||
|
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>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|
||||||
|
|||||||
@@ -3,10 +3,10 @@ jdbc.url=jdbc:mysql://121.40.189.20:3306/mediation_system?serverTimezone=Asia/Sh
|
|||||||
jdbc.user=root
|
jdbc.user=root
|
||||||
jdbc.password=YMzc157#
|
jdbc.password=YMzc157#
|
||||||
#目标模块项目路径
|
#目标模块项目路径
|
||||||
targetprojectpath=E:/WorkCode/SH/Mediation-Backend/ruoyi-system
|
targetprojectpath=D:/WorkCode/TJ/Mediation-Backend/ruoyi-system
|
||||||
#模块名称
|
#模块名称
|
||||||
moduleName=flow
|
moduleName=shortmessage
|
||||||
#表名
|
#表名
|
||||||
tableName=ms_case_flow
|
tableName=ms_sms_send_history_record
|
||||||
#主键
|
#主键
|
||||||
premaryId=id
|
premaryId=id
|
||||||
|
|||||||
Reference in New Issue
Block a user