Преглед изворни кода

新增查询加密后的明文信息接口,新增加密视频会议相关信息方法

wangqiong пре 2 година
родитељ
комит
b56288cc8c

+ 15
- 5
ruoyi-admin/src/main/java/com/ruoyi/web/controller/wisdomarbitrate/sendrecord/ShortMessageController.java Прегледај датотеку

4
 import com.ruoyi.common.core.domain.AjaxResult;
4
 import com.ruoyi.common.core.domain.AjaxResult;
5
 import com.ruoyi.wisdomarbitrate.domain.dto.sendrecord.SmsSendRecord;
5
 import com.ruoyi.wisdomarbitrate.domain.dto.sendrecord.SmsSendRecord;
6
 import com.ruoyi.wisdomarbitrate.mapper.sendrecord.SmsRecordMapper;
6
 import com.ruoyi.wisdomarbitrate.mapper.sendrecord.SmsRecordMapper;
7
-import com.ruoyi.wisdomarbitrate.service.sendrecord.ShortMessageService;
7
+import com.ruoyi.wisdomarbitrate.service.shortmessage.ShortMessageService;
8
 import org.springframework.beans.factory.annotation.Autowired;
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;
9
+import org.springframework.web.bind.annotation.*;
13
 
10
 
14
 import java.util.Date;
11
 import java.util.Date;
15
 
12
 
46
         }
43
         }
47
         return AjaxResult.error("发送失败");
44
         return AjaxResult.error("发送失败");
48
     }
45
     }
46
+
47
+    /**
48
+     * 查询UID好的密钥
49
+     */
50
+    @Anonymous
51
+    @GetMapping("/getEncryptInfoByid")
52
+    public Object getEncryptInfoByUid(@RequestParam(name = "id",required = true) String id) {
53
+        if (id != null) {
54
+            Object result = shortMessageService.getEncryptInfoByUid(id);
55
+            return result;
56
+        }
57
+        return AjaxResult.error("查询失败");
58
+    }
49
 }
59
 }

+ 2
- 1
ruoyi-admin/src/main/resources/application.yml Прегледај датотеку

217
 #    max-tasks-per-process: 100
217
 #    max-tasks-per-process: 100
218
 beimingapihost: https://zj.odrcloud.cn
218
 beimingapihost: https://zj.odrcloud.cn
219
 beimingapiprefix: /onestop/sync
219
 beimingapiprefix: /onestop/sync
220
-beimingprivatekey: d7724e72c4be93196a35203e8379ded5
220
+beimingprivatekey: d7724e72c4be93196a35203e8379ded5
221
+shortMessageKey: 936df5fd9aba3b86adc3c1a1c52dcde1

+ 8
- 1
ruoyi-common/src/main/java/com/ruoyi/common/utils/EncryptUtils.java Прегледај датотеку

112
   public static void main(String[] args) {
112
   public static void main(String[] args) {
113
     String privateKey = "936df5fd9aba3b86adc3c1a1c52dcde1";
113
     String privateKey = "936df5fd9aba3b86adc3c1a1c52dcde1";
114
     ObjectNode param = new ObjectMapper().createObjectNode();
114
     ObjectNode param = new ObjectMapper().createObjectNode();
115
-    param.put("name", "姓名");
115
+    param.put("userName", "张三");
116
+    param.put("caseNo", "ZC1234125");
117
+    param.put("userId", "124124");
118
+    param.put("roomId", "124125");
119
+    param.put("systemType", "tiaojiexitong");
116
     String encryptString = sm4Encrypt(param.toString(), privateKey);
120
     String encryptString = sm4Encrypt(param.toString(), privateKey);
117
     System.out.println("加密后的字符串:" + encryptString);
121
     System.out.println("加密后的字符串:" + encryptString);
122
+    String uid = UUID.randomUUID().toString().replace("-", "");
123
+    System.out.println("uid:" + uid);
118
     System.out.println("解密后的字符串:" + sm4Decrypt(encryptString, privateKey));
124
     System.out.println("解密后的字符串:" + sm4Decrypt(encryptString, privateKey));
125
+
119
   }
126
   }
120
 
127
 
121
 }
128
 }

+ 31
- 0
ruoyi-system/src/main/java/com/ruoyi/system/domain/entity/shortmessage/EncryptendInfo.java Прегледај датотеку

1
+package com.ruoyi.system.domain.entity.shortmessage;
2
+
3
+import java.util.Date;
4
+import javax.persistence.*;
5
+import lombok.Getter;
6
+import lombok.Setter;
7
+import lombok.ToString;
8
+
9
+@Getter
10
+@Setter
11
+@ToString
12
+@Table(name = "encryptend_info")
13
+public class EncryptendInfo {
14
+    /**
15
+     * 主键
16
+     */
17
+    @Id
18
+    private String uid;
19
+
20
+    /**
21
+     * 加密后的内容
22
+     */
23
+    @Column(name = "encrypted_content")
24
+    private String encryptedContent;
25
+
26
+    /**
27
+     * 创建时间
28
+     */
29
+    @Column(name = "create_time")
30
+    private Date createTime;
31
+}

+ 7
- 0
ruoyi-system/src/main/java/com/ruoyi/system/mapper/shortmessage/EncryptendInfoMapper.java Прегледај датотеку

1
+package com.ruoyi.system.mapper.shortmessage;
2
+
3
+import com.ruoyi.system.domain.entity.shortmessage.EncryptendInfo;
4
+import tk.mybatis.mapper.common.Mapper;
5
+
6
+public interface EncryptendInfoMapper extends Mapper<EncryptendInfo> {
7
+}

+ 21
- 0
ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/domain/vo/secret/SecretInfo.java Прегледај датотеку

1
+package com.ruoyi.wisdomarbitrate.domain.vo.secret;
2
+
3
+import lombok.AllArgsConstructor;
4
+import lombok.Builder;
5
+import lombok.Data;
6
+import lombok.NoArgsConstructor;
7
+
8
+@Data
9
+@AllArgsConstructor
10
+@NoArgsConstructor
11
+@Builder
12
+public class SecretInfo {
13
+    /**
14
+     * 用户登录名、案件编号、用户id、房间号、跳转系统类型(tiaojie、zhongcai)
15
+     */
16
+    private String userName;
17
+    private String caseNo;
18
+    private String userId;
19
+    private Integer roomId;
20
+    private String systemType;
21
+}

+ 0
- 54
ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/sendrecord/impl/ShortMessageServiceImpl.java Прегледај датотеку

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
-}

ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/sendrecord/ShortMessageService.java → ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/shortmessage/ShortMessageService.java Прегледај датотеку

1
-package com.ruoyi.wisdomarbitrate.service.sendrecord;
1
+package com.ruoyi.wisdomarbitrate.service.shortmessage;
2
 
2
 
3
 import com.ruoyi.common.core.domain.AjaxResult;
3
 import com.ruoyi.common.core.domain.AjaxResult;
4
 import com.ruoyi.system.domain.entity.shortmessage.MsSmsSendHistoryRecord;
4
 import com.ruoyi.system.domain.entity.shortmessage.MsSmsSendHistoryRecord;
5
 import com.ruoyi.system.mapper.shortmessage.MsSmsSendHistoryRecordMapper;
5
 import com.ruoyi.system.mapper.shortmessage.MsSmsSendHistoryRecordMapper;
6
 import com.ruoyi.wisdomarbitrate.domain.dto.sendrecord.SmsSendRecord;
6
 import com.ruoyi.wisdomarbitrate.domain.dto.sendrecord.SmsSendRecord;
7
+import com.ruoyi.wisdomarbitrate.domain.vo.secret.SecretInfo;
7
 
8
 
8
 public interface ShortMessageService {
9
 public interface ShortMessageService {
9
     /**
10
     /**
16
      * @param smsSendRecord
17
      * @param smsSendRecord
17
      */
18
      */
18
     AjaxResult reSendShortMessage(SmsSendRecord smsSendRecord);
19
     AjaxResult reSendShortMessage(SmsSendRecord smsSendRecord);
20
+
21
+    /**
22
+     * 根据信息生成加密信息记录
23
+     * @param secretInfo
24
+     * @return
25
+     */
26
+    String buildEncryptInfoRecord(SecretInfo secretInfo);
27
+    /**
28
+     * 通过UID查询加密信息并解密成明文对象
29
+     */
30
+    Object getEncryptInfoByUid(String uid);
19
 }
31
 }

+ 109
- 0
ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/shortmessage/impl/ShortMessageServiceImpl.java Прегледај датотеку

1
+package com.ruoyi.wisdomarbitrate.service.shortmessage.impl;
2
+
3
+import cn.hutool.json.JSONObject;
4
+import com.fasterxml.jackson.databind.ObjectMapper;
5
+import com.fasterxml.jackson.databind.node.ObjectNode;
6
+import com.ruoyi.common.core.domain.AjaxResult;
7
+import com.ruoyi.common.enums.SMSStatusEnum;
8
+import com.ruoyi.common.utils.SmsUtils;
9
+import com.ruoyi.system.domain.entity.shortmessage.EncryptendInfo;
10
+import com.ruoyi.system.domain.entity.shortmessage.MsSmsSendHistoryRecord;
11
+import com.ruoyi.system.mapper.shortmessage.EncryptendInfoMapper;
12
+import com.ruoyi.system.mapper.shortmessage.MsSmsSendHistoryRecordMapper;
13
+import com.ruoyi.wisdomarbitrate.domain.dto.sendrecord.SmsSendRecord;
14
+import com.ruoyi.wisdomarbitrate.domain.vo.secret.SecretInfo;
15
+import com.ruoyi.wisdomarbitrate.service.shortmessage.ShortMessageService;
16
+import org.springframework.beans.BeanUtils;
17
+import org.springframework.beans.factory.annotation.Autowired;
18
+import org.springframework.beans.factory.annotation.Value;
19
+import org.springframework.stereotype.Service;
20
+
21
+import java.util.UUID;
22
+
23
+import static com.ruoyi.common.utils.EncryptUtils.sm4Decrypt;
24
+import static com.ruoyi.common.utils.EncryptUtils.sm4Encrypt;
25
+
26
+@Service
27
+public class ShortMessageServiceImpl implements ShortMessageService {
28
+    @Value("${shortMessageKey}")
29
+    private String shortMessageKey;
30
+    @Autowired
31
+    MsSmsSendHistoryRecordMapper msSmsSendHistoryRecordMapper;
32
+    @Autowired
33
+    EncryptendInfoMapper encryptendInfoMapper;
34
+
35
+    /**
36
+     * 新增发送历史记录
37
+     *
38
+     * @param smsSendRecord
39
+     */
40
+    @Override
41
+    public void insertShortMessageHistoryRecord(SmsSendRecord smsSendRecord) {
42
+        if (smsSendRecord != null) {
43
+            MsSmsSendHistoryRecord historyRecord = new MsSmsSendHistoryRecord();
44
+            BeanUtils.copyProperties(smsSendRecord, historyRecord);
45
+            historyRecord.setId(null);
46
+            historyRecord.setParentId(smsSendRecord.getId());
47
+            msSmsSendHistoryRecordMapper.insert(historyRecord);
48
+        }
49
+    }
50
+
51
+    /**
52
+     * 重新发送短信
53
+     *
54
+     * @param smsSendRecord
55
+     */
56
+    @Override
57
+    public AjaxResult reSendShortMessage(SmsSendRecord smsSendRecord) {
58
+        SmsUtils.SendSmsRequest request = new SmsUtils.SendSmsRequest();
59
+        //TODO 模版id待替换
60
+        request.setTemplateId("1955047");
61
+        request.setPhone(smsSendRecord.getPhone());
62
+        request.setTemplateParamSet(new String[]{smsSendRecord.getSendContent()});
63
+        JSONObject resultObj = SmsUtils.sendSms(request);
64
+        if (resultObj.get("status") != null && !resultObj.get("status").equals(SMSStatusEnum.FAIL.getCode())) {
65
+            return AjaxResult.success("短信发送成功");
66
+        } else {
67
+            return AjaxResult.warn("短信发送失败");
68
+        }
69
+    }
70
+
71
+    /**
72
+     * 根据信息生成加密信息记录
73
+     *
74
+     * @param secretInfo
75
+     * @return
76
+     */
77
+    @Override
78
+    public String buildEncryptInfoRecord(SecretInfo secretInfo) {
79
+        String privateKey = shortMessageKey;
80
+        ObjectNode param = new ObjectMapper().createObjectNode();
81
+        param.put("userName", secretInfo.getUserName());
82
+        param.put("caseNo", secretInfo.getCaseNo());
83
+        param.put("userId", secretInfo.getUserId());
84
+        param.put("roomId", secretInfo.getRoomId());
85
+        param.put("systemType", secretInfo.getSystemType());
86
+        String encryptString = sm4Encrypt(param.toString(), privateKey);
87
+        String uid = UUID.randomUUID().toString().replace("-", "");
88
+        EncryptendInfo encryptendInfo = new EncryptendInfo();
89
+        encryptendInfo.setUid(uid);
90
+        encryptendInfo.setEncryptedContent(encryptString);
91
+        encryptendInfoMapper.insertSelective(encryptendInfo);
92
+        System.out.println("加密后的字符串:" + encryptString);
93
+        return uid;
94
+    }
95
+
96
+    /**
97
+     * 通过UID查询加密信息并解密成明文对象
98
+     *
99
+     * @param uid
100
+     */
101
+    @Override
102
+    public Object getEncryptInfoByUid(String uid) {
103
+        EncryptendInfo encryptendInfo = encryptendInfoMapper.selectByPrimaryKey(uid);
104
+        if (encryptendInfo != null) {
105
+            return sm4Decrypt(encryptendInfo.getEncryptedContent(), shortMessageKey);
106
+        }
107
+        return null;
108
+    }
109
+}

+ 12
- 0
ruoyi-system/src/main/resources/com/ruoyi/system/mapper/shortmessage/EncryptendInfoMapper.xml Прегледај датотеку

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.EncryptendInfoMapper">
4
+  <resultMap id="BaseResultMap" type="com.ruoyi.system.domain.entity.shortmessage.EncryptendInfo">
5
+    <!--
6
+      WARNING - @mbg.generated
7
+    -->
8
+    <id column="uid" jdbcType="VARCHAR" property="uid" />
9
+    <result column="encrypted_content" jdbcType="VARCHAR" property="encryptedContent" />
10
+    <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
11
+  </resultMap>
12
+</mapper>