Bladeren bron

新增短信编辑和重新发送短信接口

wangqiong 2 jaren geleden
bovenliggende
commit
dfddc6a9f4

+ 49
- 0
ruoyi-admin/src/main/java/com/ruoyi/web/controller/wisdomarbitrate/sendrecord/ShortMessageController.java Bestand weergeven

@@ -0,0 +1,49 @@
1
+package com.ruoyi.web.controller.wisdomarbitrate.sendrecord;
2
+
3
+import com.ruoyi.common.annotation.Anonymous;
4
+import com.ruoyi.common.core.domain.AjaxResult;
5
+import com.ruoyi.wisdomarbitrate.domain.dto.sendrecord.SmsSendRecord;
6
+import com.ruoyi.wisdomarbitrate.mapper.sendrecord.SmsRecordMapper;
7
+import com.ruoyi.wisdomarbitrate.service.sendrecord.ShortMessageService;
8
+import org.springframework.beans.factory.annotation.Autowired;
9
+import org.springframework.web.bind.annotation.PostMapping;
10
+import org.springframework.web.bind.annotation.RequestBody;
11
+import org.springframework.web.bind.annotation.RequestMapping;
12
+import org.springframework.web.bind.annotation.RestController;
13
+
14
+import java.util.Date;
15
+
16
+@RestController
17
+@RequestMapping("/shortMessage")
18
+public class ShortMessageController {
19
+    @Autowired
20
+    private SmsRecordMapper smsRecordMapper;
21
+    @Autowired
22
+    private ShortMessageService shortMessageService;
23
+
24
+    @Anonymous
25
+    @PostMapping("/updateSendContent")
26
+    public AjaxResult update(@RequestBody SmsSendRecord smsSendRecord) {
27
+        if (smsSendRecord != null && smsSendRecord.getId() != null) {
28
+            SmsSendRecord oldSendRecord = smsRecordMapper.selectById(smsSendRecord.getId());
29
+            smsSendRecord.setUpdateTime(new Date());
30
+            smsRecordMapper.updateSendContent(smsSendRecord);
31
+            shortMessageService.insertShortMessageHistoryRecord(oldSendRecord);
32
+            return AjaxResult.success();
33
+        }
34
+        return AjaxResult.error("更新失败");
35
+    }
36
+
37
+    /**
38
+     * 重新发送短信
39
+     */
40
+    @Anonymous
41
+    @PostMapping("/reSendShortMessage")
42
+    public AjaxResult reSendShortMessage(@RequestBody SmsSendRecord smsSendRecord) {
43
+        if (smsSendRecord != null) {
44
+            AjaxResult result = shortMessageService.reSendShortMessage(smsSendRecord);
45
+            return result;
46
+        }
47
+        return AjaxResult.error("发送失败");
48
+    }
49
+}

+ 92
- 0
ruoyi-system/src/main/java/com/ruoyi/system/domain/entity/shortmessage/MsSmsSendHistoryRecord.java Bestand weergeven

@@ -0,0 +1,92 @@
1
+package com.ruoyi.system.domain.entity.shortmessage;
2
+
3
+import java.util.Date;
4
+import javax.persistence.*;
5
+
6
+import lombok.*;
7
+
8
+@Data
9
+@AllArgsConstructor
10
+@NoArgsConstructor
11
+@Builder
12
+@Table(name = "ms_sms_send_history_record")
13
+public class MsSmsSendHistoryRecord {
14
+    @Id
15
+    @GeneratedValue(generator = "JDBC")
16
+    private Long id;
17
+
18
+    /**
19
+     * 案件id
20
+     */
21
+    @Column(name = "case_appli_id")
22
+    private Long caseAppliId;
23
+
24
+    /**
25
+     * 案件编号
26
+     */
27
+    @Column(name = "case_num")
28
+    private String caseNum;
29
+
30
+    /**
31
+     * 手机号
32
+     */
33
+    private String phone;
34
+
35
+    /**
36
+     * 发送时间
37
+     */
38
+    @Column(name = "send_time")
39
+    private Date sendTime;
40
+
41
+    /**
42
+     * 发送状态,0-失败,1-成功
43
+     */
44
+    @Column(name = "send_status")
45
+    private Long sendStatus;
46
+
47
+    /**
48
+     * 发送内容
49
+     */
50
+    @Column(name = "send_content")
51
+    private String sendContent;
52
+
53
+    /**
54
+     * 创建时间
55
+     */
56
+    @Column(name = "create_time")
57
+    private Date createTime;
58
+
59
+    /**
60
+     * 更新时间
61
+     */
62
+    @Column(name = "update_time")
63
+    private Date updateTime;
64
+
65
+    /**
66
+     * 创建人
67
+     */
68
+    @Column(name = "create_by")
69
+    private String createBy;
70
+
71
+    /**
72
+     * 更新者
73
+     */
74
+    @Column(name = "update_by")
75
+    private String updateBy;
76
+
77
+    /**
78
+     * 发送短信唯一标识
79
+     */
80
+    private String sid;
81
+
82
+    /**
83
+     * 父类短信id
84
+     */
85
+    @Column(name = "parent_id")
86
+    private Long parentId;
87
+
88
+    /**
89
+     * 失败原因
90
+     */
91
+    private String reason;
92
+}

+ 7
- 0
ruoyi-system/src/main/java/com/ruoyi/system/mapper/shortmessage/MsSmsSendHistoryRecordMapper.java Bestand weergeven

@@ -0,0 +1,7 @@
1
+package com.ruoyi.system.mapper.shortmessage;
2
+
3
+import com.ruoyi.system.domain.entity.shortmessage.MsSmsSendHistoryRecord;
4
+import tk.mybatis.mapper.common.Mapper;
5
+
6
+public interface MsSmsSendHistoryRecordMapper extends Mapper<MsSmsSendHistoryRecord> {
7
+}

+ 11
- 0
ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/mapper/sendrecord/SmsRecordMapper.java Bestand weergeven

@@ -21,4 +21,15 @@ public interface SmsRecordMapper {
21 21
     int batchSaveSmsSendRecord(@Param("list") List<SmsSendRecord> smsSendRecordList);
22 22
     SmsSendRecord selectBySId(@Param("sid") String sid);
23 23
     void updateStatus (SmsSendRecord smsSendRecord);
24
+
25
+    /**
26
+     * 更新短信发送内容
27
+     * @param smsSendRecord
28
+     * @return
29
+     */
30
+    int updateSendContent(SmsSendRecord smsSendRecord);
31
+    /**
32
+     * 通过id查询短信发送记录
33
+     */
34
+    SmsSendRecord selectById(@Param("id") Long id);
24 35
 }

+ 19
- 0
ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/sendrecord/ShortMessageService.java Bestand weergeven

@@ -0,0 +1,19 @@
1
+package com.ruoyi.wisdomarbitrate.service.sendrecord;
2
+
3
+import com.ruoyi.common.core.domain.AjaxResult;
4
+import com.ruoyi.system.domain.entity.shortmessage.MsSmsSendHistoryRecord;
5
+import com.ruoyi.system.mapper.shortmessage.MsSmsSendHistoryRecordMapper;
6
+import com.ruoyi.wisdomarbitrate.domain.dto.sendrecord.SmsSendRecord;
7
+
8
+public interface ShortMessageService {
9
+    /**
10
+     * 新增发送历史记录
11
+     */
12
+    void insertShortMessageHistoryRecord(SmsSendRecord smsSendRecord);
13
+
14
+    /**
15
+     * 重新发送短信
16
+     * @param smsSendRecord
17
+     */
18
+    AjaxResult reSendShortMessage(SmsSendRecord smsSendRecord);
19
+}

+ 54
- 0
ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/sendrecord/impl/ShortMessageServiceImpl.java Bestand weergeven

@@ -0,0 +1,54 @@
1
+package com.ruoyi.wisdomarbitrate.service.sendrecord.impl;
2
+
3
+import cn.hutool.json.JSONObject;
4
+import com.ruoyi.common.core.domain.AjaxResult;
5
+import com.ruoyi.common.enums.SMSStatusEnum;
6
+import com.ruoyi.common.utils.SmsUtils;
7
+import com.ruoyi.system.domain.entity.shortmessage.MsSmsSendHistoryRecord;
8
+import com.ruoyi.system.mapper.shortmessage.MsSmsSendHistoryRecordMapper;
9
+import com.ruoyi.wisdomarbitrate.domain.dto.sendrecord.SmsSendRecord;
10
+import com.ruoyi.wisdomarbitrate.service.sendrecord.ShortMessageService;
11
+import org.springframework.beans.BeanUtils;
12
+import org.springframework.beans.factory.annotation.Autowired;
13
+import org.springframework.stereotype.Service;
14
+
15
+@Service
16
+public class ShortMessageServiceImpl implements ShortMessageService {
17
+    @Autowired
18
+    MsSmsSendHistoryRecordMapper msSmsSendHistoryRecordMapper;
19
+    /**
20
+     * 新增发送历史记录
21
+     *
22
+     * @param smsSendRecord
23
+     */
24
+    @Override
25
+    public void insertShortMessageHistoryRecord(SmsSendRecord smsSendRecord) {
26
+        if(smsSendRecord!=null){
27
+            MsSmsSendHistoryRecord historyRecord=new MsSmsSendHistoryRecord();
28
+            BeanUtils.copyProperties(smsSendRecord,historyRecord);
29
+            historyRecord.setId(null);
30
+            historyRecord.setParentId(smsSendRecord.getId());
31
+            msSmsSendHistoryRecordMapper.insert(historyRecord);
32
+        }
33
+    }
34
+
35
+    /**
36
+     * 重新发送短信
37
+     *
38
+     * @param smsSendRecord
39
+     */
40
+    @Override
41
+    public AjaxResult reSendShortMessage(SmsSendRecord smsSendRecord) {
42
+        SmsUtils.SendSmsRequest request = new SmsUtils.SendSmsRequest();
43
+        //TODO 模版id待替换
44
+        request.setTemplateId("1955047");
45
+        request.setPhone(smsSendRecord.getPhone());
46
+        request.setTemplateParamSet(new String[]{ smsSendRecord.getSendContent()});
47
+        JSONObject resultObj = SmsUtils.sendSms(request);
48
+        if(resultObj.get("status")!=null && !resultObj.get("status").equals(SMSStatusEnum.FAIL.getCode())){
49
+            return AjaxResult.success("短信发送成功");
50
+        }else {
51
+            return AjaxResult.warn("短信发送失败");
52
+        }
53
+    }
54
+}

+ 23
- 0
ruoyi-system/src/main/resources/com/ruoyi/system/mapper/shortmessage/MsSmsSendHistoryRecordMapper.xml Bestand weergeven

@@ -0,0 +1,23 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
3
+<mapper namespace="com.ruoyi.system.mapper.shortmessage.MsSmsSendHistoryRecordMapper">
4
+  <resultMap id="BaseResultMap" type="com.ruoyi.system.domain.entity.shortmessage.MsSmsSendHistoryRecord">
5
+    <!--
6
+      WARNING - @mbg.generated
7
+    -->
8
+    <id column="id" jdbcType="BIGINT" property="id" />
9
+    <result column="case_appli_id" jdbcType="BIGINT" property="caseAppliId" />
10
+    <result column="case_num" jdbcType="VARCHAR" property="caseNum" />
11
+    <result column="phone" jdbcType="VARCHAR" property="phone" />
12
+    <result column="send_time" jdbcType="TIMESTAMP" property="sendTime" />
13
+    <result column="send_status" jdbcType="BIGINT" property="sendStatus" />
14
+    <result column="send_content" jdbcType="VARCHAR" property="sendContent" />
15
+    <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
16
+    <result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
17
+    <result column="create_by" jdbcType="VARCHAR" property="createBy" />
18
+    <result column="update_by" jdbcType="VARCHAR" property="updateBy" />
19
+    <result column="sid" jdbcType="VARCHAR" property="sid" />
20
+    <result column="parent_id" jdbcType="BIGINT" property="parentId" />
21
+    <result column="reason" jdbcType="LONGVARCHAR" property="reason" />
22
+  </resultMap>
23
+</mapper>

+ 8
- 0
ruoyi-system/src/main/resources/mapper/wisdomarbitrate/sendrecord/SmsRecordMapper.xml Bestand weergeven

@@ -91,5 +91,13 @@
91 91
         update ms_sms_send_record
92 92
        set send_status= #{sendStatus} ,reason=#{reason} where sid=#{sid}
93 93
     </update>
94
+    <update id="updateSendContent">
95
+        update ms_sms_send_record
96
+        set send_content= #{sendContent} ,update_time=#{updateTime} where id=#{id}
97
+    </update>
98
+
99
+    <select id="selectById" resultMap="SmsSendRecordResult">
100
+        select  * from ms_sms_send_record where id=#{id}
101
+    </select>
94 102
 </mapper>
95 103
 

+ 3
- 3
tkgenerator/src/main/resources/generator/config.properties Bestand weergeven

@@ -3,10 +3,10 @@ jdbc.url=jdbc:mysql://121.40.189.20:3306/mediation_system?serverTimezone=Asia/Sh
3 3
 jdbc.user=root
4 4
 jdbc.password=YMzc157#
5 5
 #目标模块项目路径
6
-targetprojectpath=E:/WorkCode/SH/Mediation-Backend/ruoyi-system
6
+targetprojectpath=D:/WorkCode/TJ/Mediation-Backend/ruoyi-system
7 7
 #模块名称
8
-moduleName=flow
8
+moduleName=shortmessage
9 9
 #表名
10
-tableName=ms_case_flow
10
+tableName=ms_sms_send_history_record
11 11
 #主键
12 12
 premaryId=id