优化短信跳转链接
This commit is contained in:
+4
-4
@@ -48,10 +48,10 @@ public class ShortMessageController {
|
||||
* 查询UID好的密钥
|
||||
*/
|
||||
@Anonymous
|
||||
@GetMapping("/getEncryptInfoByid")
|
||||
public Object getEncryptInfoByUid(@RequestParam(name = "id",required = true) String id) {
|
||||
if (id != null) {
|
||||
Object result = shortMessageService.getEncryptInfoByUid(id);
|
||||
@GetMapping("/getMeetingInfo")
|
||||
public Object getEncryptInfoByUid(@RequestParam(name = "authId", required = true) String authId) {
|
||||
if (authId != null) {
|
||||
Object result = shortMessageService.getMeetingInfo(authId);
|
||||
return result;
|
||||
}
|
||||
return AjaxResult.error("查询失败");
|
||||
|
||||
@@ -218,4 +218,3 @@ BMConfig:
|
||||
beimingapihost: https://zj.odrcloud.cn
|
||||
beimingapiprefix: /onestop/sync
|
||||
beimingprivatekey: d7724e72c4be93196a35203e8379ded5
|
||||
shortMessageKey: 936df5fd9aba3b86adc3c1a1c52dcde1
|
||||
@@ -4,11 +4,10 @@ import io.jsonwebtoken.Claims;
|
||||
|
||||
/**
|
||||
* 通用常量信息
|
||||
*
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
public class Constants
|
||||
{
|
||||
public class Constants {
|
||||
/**
|
||||
* UTF-8 字符集
|
||||
*/
|
||||
@@ -71,7 +70,7 @@ public class Constants
|
||||
* 登录失败
|
||||
*/
|
||||
public static final String LOGIN_FAIL = "Error";
|
||||
|
||||
|
||||
/**
|
||||
* 验证码有效期(分钟)
|
||||
*/
|
||||
@@ -95,6 +94,10 @@ public class Constants
|
||||
* 令牌前缀
|
||||
*/
|
||||
public static final String LOGIN_USER_KEY = "login_user_key";
|
||||
/**
|
||||
* 会议主键Id
|
||||
*/
|
||||
public static final String MEETING_KEY = "meeting_key";
|
||||
|
||||
/**
|
||||
* 用户ID
|
||||
@@ -142,23 +145,22 @@ public class Constants
|
||||
public static final String LOOKUP_LDAPS = "ldaps:";
|
||||
public static final String DEFAULT_PASSWORD = "123456";
|
||||
// 英文逗号分隔符
|
||||
public static final String SPLIT_COMMA =",";
|
||||
public static final String SPLIT_COMMA = ",";
|
||||
// 中文逗号分隔符
|
||||
public static final String CN_SPLIT_COMMA =",";
|
||||
public static final String CN_SPLIT_COMMA = ",";
|
||||
|
||||
/**
|
||||
* 自动识别json对象白名单配置(仅允许解析的包名,范围越小越安全)
|
||||
*/
|
||||
public static final String[] JSON_WHITELIST_STR = { "org.springframework", "com.ruoyi" };
|
||||
public static final String[] JSON_WHITELIST_STR = {"org.springframework", "com.ruoyi"};
|
||||
|
||||
/**
|
||||
* 定时任务白名单配置(仅允许访问的包名,如其他需要可以自行添加)
|
||||
*/
|
||||
public static final String[] JOB_WHITELIST_STR = { "com.ruoyi" };
|
||||
public static final String[] JOB_WHITELIST_STR = {"com.ruoyi"};
|
||||
|
||||
/**
|
||||
* 定时任务违规的字符
|
||||
*/
|
||||
public static final String[] JOB_ERROR_STR = { "java.net.URL", "javax.naming.InitialContext", "org.yaml.snakeyaml",
|
||||
"org.springframework", "org.apache", "com.ruoyi.common.utils.file", "com.ruoyi.common.config" };
|
||||
public static final String[] JOB_ERROR_STR = {"java.net.URL", "javax.naming.InitialContext", "org.yaml.snakeyaml", "org.springframework", "org.apache", "com.ruoyi.common.utils.file", "com.ruoyi.common.config"};
|
||||
}
|
||||
|
||||
-31
@@ -1,31 +0,0 @@
|
||||
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 = "encryptend_info")
|
||||
public class EncryptendInfo {
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
@Id
|
||||
private String uid;
|
||||
|
||||
/**
|
||||
* 加密后的内容
|
||||
*/
|
||||
@Column(name = "encrypted_content")
|
||||
private String encryptedContent;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@Column(name = "create_time")
|
||||
private Date createTime;
|
||||
}
|
||||
+60
@@ -0,0 +1,60 @@
|
||||
package com.ruoyi.system.domain.entity.shortmessage;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Table(name = "meeting_info")
|
||||
public class MeetingInfo {
|
||||
/**
|
||||
* 主键Id
|
||||
*/
|
||||
@Id
|
||||
private String uid;
|
||||
|
||||
/**
|
||||
* 案件Id
|
||||
*/
|
||||
@Column(name = "case_id")
|
||||
private Long caseId;
|
||||
|
||||
/**
|
||||
* 用户Id
|
||||
*/
|
||||
@Column(name = "user_id")
|
||||
private Long userId;
|
||||
|
||||
/**
|
||||
* 用户名称
|
||||
*/
|
||||
@Column(name = "user_name")
|
||||
private String userName;
|
||||
|
||||
/**
|
||||
* 房间Id
|
||||
*/
|
||||
@Column(name = "room_id")
|
||||
private String roomId;
|
||||
|
||||
/**
|
||||
* 系统类型
|
||||
*/
|
||||
@Column(name = "system_type")
|
||||
private String systemType;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@Column(name = "create_time")
|
||||
private Date createTime;
|
||||
}
|
||||
-7
@@ -1,7 +0,0 @@
|
||||
package com.ruoyi.system.mapper.shortmessage;
|
||||
|
||||
import com.ruoyi.system.domain.entity.shortmessage.EncryptendInfo;
|
||||
import tk.mybatis.mapper.common.Mapper;
|
||||
|
||||
public interface EncryptendInfoMapper extends Mapper<EncryptendInfo> {
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package com.ruoyi.system.mapper.shortmessage;
|
||||
|
||||
import com.ruoyi.system.domain.entity.shortmessage.MeetingInfo;
|
||||
import tk.mybatis.mapper.common.Mapper;
|
||||
|
||||
public interface MeetingInfoMapper extends Mapper<MeetingInfo> {
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
package com.ruoyi.wisdomarbitrate.domain.vo.secret;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Builder
|
||||
public class SecretInfo {
|
||||
/**
|
||||
* 用户登录名、案件编号、用户id、房间号、跳转系统类型(tiaojie、zhongcai)
|
||||
*/
|
||||
private String userName;
|
||||
private String caseNo;
|
||||
private String userId;
|
||||
private Integer roomId;
|
||||
private String systemType;
|
||||
}
|
||||
+41
@@ -0,0 +1,41 @@
|
||||
package com.ruoyi.wisdomarbitrate.domain.vo.shortmessage;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class MeetingInfoVO {
|
||||
/**
|
||||
* 案件Id
|
||||
*/
|
||||
private Long caseId;
|
||||
|
||||
/**
|
||||
* 用户Id
|
||||
*/
|
||||
private Long userId;
|
||||
|
||||
/**
|
||||
* 用户名称
|
||||
*/
|
||||
private String userName;
|
||||
|
||||
/**
|
||||
* 房间Id
|
||||
*/
|
||||
private String roomId;
|
||||
|
||||
/**
|
||||
* 系统类型
|
||||
*/
|
||||
private String systemType;
|
||||
/**
|
||||
* 登录认证令牌
|
||||
*/
|
||||
private String token;
|
||||
}
|
||||
+7
-6
@@ -1,10 +1,8 @@
|
||||
package com.ruoyi.wisdomarbitrate.service.shortmessage;
|
||||
|
||||
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;
|
||||
import com.ruoyi.wisdomarbitrate.domain.vo.secret.SecretInfo;
|
||||
import com.ruoyi.wisdomarbitrate.domain.vo.shortmessage.MeetingInfoVO;
|
||||
|
||||
public interface ShortMessageService {
|
||||
/**
|
||||
@@ -14,18 +12,21 @@ public interface ShortMessageService {
|
||||
|
||||
/**
|
||||
* 重新发送短信
|
||||
*
|
||||
* @param smsSendRecord
|
||||
*/
|
||||
AjaxResult reSendShortMessage(SmsSendRecord smsSendRecord);
|
||||
|
||||
/**
|
||||
* 根据信息生成加密信息记录
|
||||
* @param secretInfo
|
||||
*
|
||||
* @param meetingInfoVO
|
||||
* @return
|
||||
*/
|
||||
String buildEncryptInfoRecord(SecretInfo secretInfo);
|
||||
String buildMeetingInfoRecord(MeetingInfoVO meetingInfoVO);
|
||||
|
||||
/**
|
||||
* 通过UID查询加密信息并解密成明文对象
|
||||
*/
|
||||
Object getEncryptInfoByUid(String uid);
|
||||
Object getMeetingInfo(String uid);
|
||||
}
|
||||
|
||||
+38
-30
@@ -1,36 +1,35 @@
|
||||
package com.ruoyi.wisdomarbitrate.service.shortmessage.impl;
|
||||
|
||||
import cn.hutool.json.JSONObject;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
import com.ruoyi.common.constant.Constants;
|
||||
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.EncryptendInfo;
|
||||
import com.ruoyi.system.domain.entity.shortmessage.MeetingInfo;
|
||||
import com.ruoyi.system.domain.entity.shortmessage.MsSmsSendHistoryRecord;
|
||||
import com.ruoyi.system.mapper.shortmessage.EncryptendInfoMapper;
|
||||
import com.ruoyi.system.mapper.shortmessage.MeetingInfoMapper;
|
||||
import com.ruoyi.system.mapper.shortmessage.MsSmsSendHistoryRecordMapper;
|
||||
import com.ruoyi.wisdomarbitrate.domain.dto.sendrecord.SmsSendRecord;
|
||||
import com.ruoyi.wisdomarbitrate.domain.vo.secret.SecretInfo;
|
||||
import com.ruoyi.wisdomarbitrate.domain.vo.shortmessage.MeetingInfoVO;
|
||||
import com.ruoyi.wisdomarbitrate.service.shortmessage.ShortMessageService;
|
||||
import io.jsonwebtoken.Jwts;
|
||||
import io.jsonwebtoken.SignatureAlgorithm;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import static com.ruoyi.common.utils.EncryptUtils.sm4Decrypt;
|
||||
import static com.ruoyi.common.utils.EncryptUtils.sm4Encrypt;
|
||||
|
||||
@Service
|
||||
public class ShortMessageServiceImpl implements ShortMessageService {
|
||||
@Value("${shortMessageKey}")
|
||||
private String shortMessageKey;
|
||||
@Autowired
|
||||
MsSmsSendHistoryRecordMapper msSmsSendHistoryRecordMapper;
|
||||
@Autowired
|
||||
EncryptendInfoMapper encryptendInfoMapper;
|
||||
MeetingInfoMapper meetingInfoMapper;
|
||||
|
||||
/**
|
||||
* 新增发送历史记录
|
||||
@@ -71,25 +70,15 @@ public class ShortMessageServiceImpl implements ShortMessageService {
|
||||
/**
|
||||
* 根据信息生成加密信息记录
|
||||
*
|
||||
* @param secretInfo
|
||||
* @param meetingInfoVO
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public String buildEncryptInfoRecord(SecretInfo secretInfo) {
|
||||
String privateKey = shortMessageKey;
|
||||
ObjectNode param = new ObjectMapper().createObjectNode();
|
||||
param.put("userName", secretInfo.getUserName());
|
||||
param.put("caseNo", secretInfo.getCaseNo());
|
||||
param.put("userId", secretInfo.getUserId());
|
||||
param.put("roomId", secretInfo.getRoomId());
|
||||
param.put("systemType", secretInfo.getSystemType());
|
||||
String encryptString = sm4Encrypt(param.toString(), privateKey);
|
||||
public String buildMeetingInfoRecord(MeetingInfoVO meetingInfoVO) {
|
||||
String uid = UUID.randomUUID().toString().replace("-", "");
|
||||
EncryptendInfo encryptendInfo = new EncryptendInfo();
|
||||
encryptendInfo.setUid(uid);
|
||||
encryptendInfo.setEncryptedContent(encryptString);
|
||||
encryptendInfoMapper.insertSelective(encryptendInfo);
|
||||
System.out.println("加密后的字符串:" + encryptString);
|
||||
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();
|
||||
meetingInfo.setUid(uid);
|
||||
meetingInfoMapper.insertSelective(meetingInfo);
|
||||
return uid;
|
||||
}
|
||||
|
||||
@@ -99,11 +88,30 @@ public class ShortMessageServiceImpl implements ShortMessageService {
|
||||
* @param uid
|
||||
*/
|
||||
@Override
|
||||
public Object getEncryptInfoByUid(String uid) {
|
||||
EncryptendInfo encryptendInfo = encryptendInfoMapper.selectByPrimaryKey(uid);
|
||||
if (encryptendInfo != null) {
|
||||
return sm4Decrypt(encryptendInfo.getEncryptedContent(), shortMessageKey);
|
||||
public Object getMeetingInfo(String uid) {
|
||||
MeetingInfoVO result = new MeetingInfoVO();
|
||||
MeetingInfo meetingInfo = meetingInfoMapper.selectByPrimaryKey(uid);
|
||||
if (meetingInfo != null) {
|
||||
BeanUtils.copyProperties(meetingInfo, result);
|
||||
if (result != null) {
|
||||
Map<String, Object> claims = new HashMap<>();
|
||||
claims.put("userName", meetingInfo.getUserName());
|
||||
claims.put("userId", meetingInfo.getUserId());
|
||||
claims.put(Constants.MEETING_KEY, uid);
|
||||
String createToken = createToken(claims);
|
||||
result.setToken(createToken);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// 令牌秘钥
|
||||
@Value("${token.secret}")
|
||||
private String secret;
|
||||
|
||||
private String createToken(Map<String, Object> claims) {
|
||||
String token = Jwts.builder().setClaims(claims).signWith(SignatureAlgorithm.HS512, secret).compact();
|
||||
return token;
|
||||
}
|
||||
}
|
||||
|
||||
-12
@@ -1,12 +0,0 @@
|
||||
<?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.EncryptendInfoMapper">
|
||||
<resultMap id="BaseResultMap" type="com.ruoyi.system.domain.entity.shortmessage.EncryptendInfo">
|
||||
<!--
|
||||
WARNING - @mbg.generated
|
||||
-->
|
||||
<id column="uid" jdbcType="VARCHAR" property="uid" />
|
||||
<result column="encrypted_content" jdbcType="VARCHAR" property="encryptedContent" />
|
||||
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
|
||||
</resultMap>
|
||||
</mapper>
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
<?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.MeetingInfoMapper">
|
||||
<resultMap id="BaseResultMap" type="com.ruoyi.system.domain.entity.shortmessage.MeetingInfo">
|
||||
<!--
|
||||
WARNING - @mbg.generated
|
||||
-->
|
||||
<id column="uid" jdbcType="VARCHAR" property="uid" />
|
||||
<result column="case_id" jdbcType="BIGINT" property="caseId" />
|
||||
<result column="user_id" jdbcType="BIGINT" property="userId" />
|
||||
<result column="user_name" jdbcType="VARCHAR" property="userName" />
|
||||
<result column="room_id" jdbcType="VARCHAR" property="roomId" />
|
||||
<result column="system_type" jdbcType="VARCHAR" property="systemType" />
|
||||
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
|
||||
</resultMap>
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user