|
|
@@ -1,36 +1,35 @@
|
|
1
|
1
|
package com.ruoyi.wisdomarbitrate.service.shortmessage.impl;
|
|
2
|
2
|
|
|
3
|
3
|
import cn.hutool.json.JSONObject;
|
|
4
|
|
-import com.fasterxml.jackson.databind.ObjectMapper;
|
|
5
|
|
-import com.fasterxml.jackson.databind.node.ObjectNode;
|
|
|
4
|
+import com.ruoyi.common.constant.Constants;
|
|
6
|
5
|
import com.ruoyi.common.core.domain.AjaxResult;
|
|
7
|
6
|
import com.ruoyi.common.enums.SMSStatusEnum;
|
|
8
|
7
|
import com.ruoyi.common.utils.SmsUtils;
|
|
9
|
|
-import com.ruoyi.system.domain.entity.shortmessage.EncryptendInfo;
|
|
|
8
|
+import com.ruoyi.system.domain.entity.shortmessage.MeetingInfo;
|
|
10
|
9
|
import com.ruoyi.system.domain.entity.shortmessage.MsSmsSendHistoryRecord;
|
|
11
|
|
-import com.ruoyi.system.mapper.shortmessage.EncryptendInfoMapper;
|
|
|
10
|
+import com.ruoyi.system.mapper.shortmessage.MeetingInfoMapper;
|
|
12
|
11
|
import com.ruoyi.system.mapper.shortmessage.MsSmsSendHistoryRecordMapper;
|
|
13
|
12
|
import com.ruoyi.wisdomarbitrate.domain.dto.sendrecord.SmsSendRecord;
|
|
14
|
|
-import com.ruoyi.wisdomarbitrate.domain.vo.secret.SecretInfo;
|
|
|
13
|
+import com.ruoyi.wisdomarbitrate.domain.vo.shortmessage.MeetingInfoVO;
|
|
15
|
14
|
import com.ruoyi.wisdomarbitrate.service.shortmessage.ShortMessageService;
|
|
|
15
|
+import io.jsonwebtoken.Jwts;
|
|
|
16
|
+import io.jsonwebtoken.SignatureAlgorithm;
|
|
16
|
17
|
import org.springframework.beans.BeanUtils;
|
|
17
|
18
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
18
|
19
|
import org.springframework.beans.factory.annotation.Value;
|
|
19
|
20
|
import org.springframework.stereotype.Service;
|
|
20
|
21
|
|
|
|
22
|
+import java.util.Date;
|
|
|
23
|
+import java.util.HashMap;
|
|
|
24
|
+import java.util.Map;
|
|
21
|
25
|
import java.util.UUID;
|
|
22
|
26
|
|
|
23
|
|
-import static com.ruoyi.common.utils.EncryptUtils.sm4Decrypt;
|
|
24
|
|
-import static com.ruoyi.common.utils.EncryptUtils.sm4Encrypt;
|
|
25
|
|
-
|
|
26
|
27
|
@Service
|
|
27
|
28
|
public class ShortMessageServiceImpl implements ShortMessageService {
|
|
28
|
|
- @Value("${shortMessageKey}")
|
|
29
|
|
- private String shortMessageKey;
|
|
30
|
29
|
@Autowired
|
|
31
|
30
|
MsSmsSendHistoryRecordMapper msSmsSendHistoryRecordMapper;
|
|
32
|
31
|
@Autowired
|
|
33
|
|
- EncryptendInfoMapper encryptendInfoMapper;
|
|
|
32
|
+ MeetingInfoMapper meetingInfoMapper;
|
|
34
|
33
|
|
|
35
|
34
|
/**
|
|
36
|
35
|
* 新增发送历史记录
|
|
|
@@ -71,25 +70,15 @@ public class ShortMessageServiceImpl implements ShortMessageService {
|
|
71
|
70
|
/**
|
|
72
|
71
|
* 根据信息生成加密信息记录
|
|
73
|
72
|
*
|
|
74
|
|
- * @param secretInfo
|
|
|
73
|
+ * @param meetingInfoVO
|
|
75
|
74
|
* @return
|
|
76
|
75
|
*/
|
|
77
|
76
|
@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);
|
|
|
77
|
+ public String buildMeetingInfoRecord(MeetingInfoVO meetingInfoVO) {
|
|
87
|
78
|
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);
|
|
|
79
|
+ MeetingInfo meetingInfo = MeetingInfo.builder().userId(meetingInfoVO.getUserId()).userName(meetingInfoVO.getUserName()).caseId(meetingInfoVO.getCaseId()).roomId(meetingInfoVO.getRoomId()).systemType(meetingInfoVO.getSystemType()).createTime(new Date()).uid(uid).build();
|
|
|
80
|
+ meetingInfo.setUid(uid);
|
|
|
81
|
+ meetingInfoMapper.insertSelective(meetingInfo);
|
|
93
|
82
|
return uid;
|
|
94
|
83
|
}
|
|
95
|
84
|
|
|
|
@@ -99,11 +88,30 @@ public class ShortMessageServiceImpl implements ShortMessageService {
|
|
99
|
88
|
* @param uid
|
|
100
|
89
|
*/
|
|
101
|
90
|
@Override
|
|
102
|
|
- public Object getEncryptInfoByUid(String uid) {
|
|
103
|
|
- EncryptendInfo encryptendInfo = encryptendInfoMapper.selectByPrimaryKey(uid);
|
|
104
|
|
- if (encryptendInfo != null) {
|
|
105
|
|
- return sm4Decrypt(encryptendInfo.getEncryptedContent(), shortMessageKey);
|
|
|
91
|
+ public Object getMeetingInfo(String uid) {
|
|
|
92
|
+ MeetingInfoVO result = new MeetingInfoVO();
|
|
|
93
|
+ MeetingInfo meetingInfo = meetingInfoMapper.selectByPrimaryKey(uid);
|
|
|
94
|
+ if (meetingInfo != null) {
|
|
|
95
|
+ BeanUtils.copyProperties(meetingInfo, result);
|
|
|
96
|
+ if (result != null) {
|
|
|
97
|
+ Map<String, Object> claims = new HashMap<>();
|
|
|
98
|
+ claims.put("userName", meetingInfo.getUserName());
|
|
|
99
|
+ claims.put("userId", meetingInfo.getUserId());
|
|
|
100
|
+ claims.put(Constants.MEETING_KEY, uid);
|
|
|
101
|
+ String createToken = createToken(claims);
|
|
|
102
|
+ result.setToken(createToken);
|
|
|
103
|
+ }
|
|
|
104
|
+ return result;
|
|
106
|
105
|
}
|
|
107
|
106
|
return null;
|
|
108
|
107
|
}
|
|
|
108
|
+
|
|
|
109
|
+ // 令牌秘钥
|
|
|
110
|
+ @Value("${token.secret}")
|
|
|
111
|
+ private String secret;
|
|
|
112
|
+
|
|
|
113
|
+ private String createToken(Map<String, Object> claims) {
|
|
|
114
|
+ String token = Jwts.builder().setClaims(claims).signWith(SignatureAlgorithm.HS512, secret).compact();
|
|
|
115
|
+ return token;
|
|
|
116
|
+ }
|
|
109
|
117
|
}
|