mirror of
https://gitee.com/republicline/rax-remote-v2.git
synced 2025-08-24 07:24:58 +08:00
parent
8d176fc965
commit
9355c44b13
|
@ -314,14 +314,16 @@ public abstract class OAuth2ResourceOwnerBaseAuthenticationProvider<T extends OA
|
||||||
String previousAccessToken = redisTemplate.opsForValue().get(LOGGED_IN + username + "::a::");
|
String previousAccessToken = redisTemplate.opsForValue().get(LOGGED_IN + username + "::a::");
|
||||||
String previousRefreshToken = redisTemplate.opsForValue().get(LOGGED_IN + username + "::c::");
|
String previousRefreshToken = redisTemplate.opsForValue().get(LOGGED_IN + username + "::c::");
|
||||||
String accessToken = authorization.getAccessToken().getToken().getTokenValue();
|
String accessToken = authorization.getAccessToken().getToken().getTokenValue();
|
||||||
String refreshToken = authorization.getRefreshToken().getToken().getTokenValue();
|
|
||||||
if (StringUtils.hasText(previousAccessToken)) {
|
if (StringUtils.hasText(previousAccessToken)) {
|
||||||
redisTemplate.delete("token::access_token::" + previousAccessToken);
|
redisTemplate.delete("token::access_token::" + previousAccessToken);
|
||||||
redisTemplate.delete("token::refresh_token::" + previousRefreshToken);
|
redisTemplate.delete("token::refresh_token::" + previousRefreshToken);
|
||||||
}
|
}
|
||||||
R<SysOauthClientDetails> clientDetailsById = clientDetailsService.getClientDetailsById(authorization.getRegisteredClientId(), SecurityConstants.FROM_IN);
|
R<SysOauthClientDetails> clientDetailsById = clientDetailsService.getClientDetailsById(authorization.getRegisteredClientId(), SecurityConstants.FROM_IN);
|
||||||
redisTemplate.opsForValue().set(LOGGED_IN + username + "::a::", accessToken, clientDetailsById.getData().getAccessTokenValidity(), TimeUnit.SECONDS);
|
redisTemplate.opsForValue().set(LOGGED_IN + username + "::a::", accessToken, clientDetailsById.getData().getAccessTokenValidity(), TimeUnit.SECONDS);
|
||||||
redisTemplate.opsForValue().set(LOGGED_IN + username + "::c::", refreshToken, clientDetailsById.getData().getRefreshTokenValidity(), TimeUnit.SECONDS);
|
if (authorization.getRefreshToken() != null) {
|
||||||
|
String refreshToken = authorization.getRefreshToken().getToken().getTokenValue();
|
||||||
|
redisTemplate.opsForValue().set(LOGGED_IN + username + "::c::", refreshToken, clientDetailsById.getData().getRefreshTokenValidity(), TimeUnit.SECONDS);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,7 @@ public interface CommonConstants {
|
||||||
/**
|
/**
|
||||||
* 锁定
|
* 锁定
|
||||||
*/
|
*/
|
||||||
String STATUS_LOCK = "9";
|
String STATUS_LOCK = "1";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 菜单树根节点
|
* 菜单树根节点
|
||||||
|
|
27
db/pig.sql
27
db/pig.sql
|
@ -1,11 +1,11 @@
|
||||||
DROP DATABASE IF EXISTS `pig`;
|
DROP DATABASE IF EXISTS `rax_backend`;
|
||||||
|
|
||||||
CREATE DATABASE `pig` DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_bin;
|
CREATE DATABASE `rax_backend` DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_bin;
|
||||||
|
|
||||||
SET NAMES utf8mb4;
|
SET NAMES utf8mb4;
|
||||||
SET FOREIGN_KEY_CHECKS = 0;
|
SET FOREIGN_KEY_CHECKS = 0;
|
||||||
|
|
||||||
USE `pig`;
|
USE `rax_backend`;
|
||||||
|
|
||||||
|
|
||||||
-- ----------------------------
|
-- ----------------------------
|
||||||
|
@ -725,5 +725,26 @@ CREATE TABLE `sys_job_log` (
|
||||||
PRIMARY KEY (`job_log_id`) USING BTREE
|
PRIMARY KEY (`job_log_id`) USING BTREE
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='定时任务执行日志表';
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='定时任务执行日志表';
|
||||||
|
|
||||||
|
DROP TABLE IF EXISTS `sys_hospital`;
|
||||||
|
CREATE TABLE `sys_hospital` (
|
||||||
|
`id` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL,
|
||||||
|
`name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '医院名称',
|
||||||
|
`code` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL,
|
||||||
|
`start_time` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL,
|
||||||
|
`end_time` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL,
|
||||||
|
`status` bit(1) NULL DEFAULT NULL,
|
||||||
|
`domain` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL,
|
||||||
|
`create_time` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL,
|
||||||
|
`deleted` bit(1) NULL DEFAULT NULL,
|
||||||
|
`update_time` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL,
|
||||||
|
`province` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL,
|
||||||
|
`city` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL,
|
||||||
|
PRIMARY KEY (`id`) USING BTREE
|
||||||
|
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_bin ROW_FORMAT = Dynamic;
|
||||||
|
|
||||||
|
-- ----------------------------
|
||||||
|
-- Records of sys_hospital
|
||||||
|
-- ----------------------------
|
||||||
|
INSERT INTO `sys_hospital` VALUES ('111', '111', '111', '111', '111', b'1', '111', '11', b'0', '111', '11', '111');
|
||||||
|
|
||||||
SET FOREIGN_KEY_CHECKS = 1;
|
SET FOREIGN_KEY_CHECKS = 1;
|
||||||
|
|
|
@ -11,13 +11,13 @@ spring:
|
||||||
type: redis
|
type: redis
|
||||||
data:
|
data:
|
||||||
redis:
|
redis:
|
||||||
host: 192.168.65.130
|
host: localhost
|
||||||
# 数据库相关配置
|
# 数据库相关配置
|
||||||
datasource:
|
datasource:
|
||||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||||
username: root
|
username: root
|
||||||
password: root
|
password: root
|
||||||
url: jdbc:mysql://192.168.65.130:3306/rax_backend?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&allowPublicKeyRetrieval=true&useSSL=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2B8&allowMultiQueries=true&nullCatalogMeansCurrent=true
|
url: jdbc:mysql://localhost:3306/rax_backend?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&allowPublicKeyRetrieval=true&useSSL=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2B8&allowMultiQueries=true&nullCatalogMeansCurrent=true
|
||||||
# 定时任务属性配置
|
# 定时任务属性配置
|
||||||
quartz:
|
quartz:
|
||||||
properties:
|
properties:
|
||||||
|
@ -101,10 +101,10 @@ mybatis-plus:
|
||||||
|
|
||||||
vital-sign:
|
vital-sign:
|
||||||
mongodb:
|
mongodb:
|
||||||
host: 192.168.65.130:27017
|
host: localhost:27017
|
||||||
password: root
|
password: root
|
||||||
username: root
|
username: root
|
||||||
mysql:
|
mysql:
|
||||||
host: 192.168.65.130:3306
|
host: localhost:3306
|
||||||
password: root
|
password: root
|
||||||
username: root
|
username: root
|
||||||
|
|
|
@ -11,7 +11,9 @@ import org.springframework.security.oauth2.server.authorization.OAuth2Authorizat
|
||||||
import org.springframework.security.oauth2.server.authorization.OAuth2AuthorizationService;
|
import org.springframework.security.oauth2.server.authorization.OAuth2AuthorizationService;
|
||||||
import org.springframework.security.oauth2.server.authorization.OAuth2TokenType;
|
import org.springframework.security.oauth2.server.authorization.OAuth2TokenType;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.util.LinkedMultiValueMap;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
@Controller
|
@Controller
|
||||||
|
@ -25,21 +27,23 @@ public class ChatController {
|
||||||
|
|
||||||
@MessageMapping("/sendMessage")
|
@MessageMapping("/sendMessage")
|
||||||
public void sendMessage(MessageHeaders messageHeaders, String body) {
|
public void sendMessage(MessageHeaders messageHeaders, String body) {
|
||||||
JSONObject params = JSONObject.parseObject(body);
|
LinkedMultiValueMap nativeHeaders = (LinkedMultiValueMap) messageHeaders.get("nativeHeaders");
|
||||||
OAuth2Authorization authorization = authorizationService.findByToken(params.getString("token"), OAuth2TokenType.ACCESS_TOKEN);
|
ArrayList tokenList = (ArrayList) nativeHeaders.get("token");
|
||||||
|
String token = (String) tokenList.get(0);
|
||||||
|
OAuth2Authorization authorization = authorizationService.findByToken(token, OAuth2TokenType.ACCESS_TOKEN);
|
||||||
if (authorization != null) {
|
if (authorization != null) {
|
||||||
String username = authorization.getPrincipalName();
|
String username = authorization.getPrincipalName();
|
||||||
String simpSessionId = messageHeaders.get("simpSessionId", String.class);
|
String simpSessionId = messageHeaders.get("simpSessionId", String.class);
|
||||||
|
JSONObject params = JSONObject.parseObject(body);
|
||||||
// 病人名
|
// 病人名
|
||||||
String patientName = params.getString("patientName");
|
String patientName = params.getString("patientName");
|
||||||
// 病人身份证
|
// 病人身份证
|
||||||
String idNum = params.getString("idNum");
|
String idNum = params.getString("idNum");
|
||||||
// yyyyMMdd
|
// yyyyMMdd
|
||||||
String date = params.getString("date");
|
String date = params.getString("date");
|
||||||
String databaseName = DatabaseNameUtil.encrypt(patientName) + "_" + DatabaseNameUtil.encrypt(idNum) + "_" + date;
|
|
||||||
// 消息内容
|
// 消息内容
|
||||||
String msg = params.getString("msg");
|
String msg = params.getString("msg");
|
||||||
chatService.sendMessage(databaseName, username, simpSessionId, msg);
|
chatService.sendMessage(username, patientName, idNum, date, simpSessionId, msg);
|
||||||
} else {
|
} else {
|
||||||
throw new AccessDeniedException("Access is denied");
|
throw new AccessDeniedException("Access is denied");
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package com.rax.vital.medicine.service;
|
package com.rax.vital.medicine.service;
|
||||||
|
|
||||||
public interface ChatService {
|
public interface ChatService {
|
||||||
void sendMessage(String db, String username, String simpSessionId, String msg);
|
void sendMessage(String username, String patientName, String idNum, String date, String simpSessionId, String msg);
|
||||||
|
|
||||||
void stopTimerTaskMongo(String simpSessionId);
|
void stopTimerTaskMongo(String simpSessionId);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,16 @@
|
||||||
package com.rax.vital.medicine.service.impl;
|
package com.rax.vital.medicine.service.impl;
|
||||||
|
|
||||||
import cn.hutool.core.date.DateUtil;
|
import cn.hutool.core.date.DateUtil;
|
||||||
|
import com.rax.admin.api.dto.UserDTO;
|
||||||
|
import com.rax.admin.api.dto.UserInfo;
|
||||||
|
import com.rax.admin.api.feign.RemoteUserService;
|
||||||
|
import com.rax.common.core.constant.SecurityConstants;
|
||||||
|
import com.rax.common.core.util.R;
|
||||||
import com.rax.vital.datasource.MongoDBSource;
|
import com.rax.vital.datasource.MongoDBSource;
|
||||||
import com.rax.vital.medicine.service.ChatService;
|
import com.rax.vital.medicine.service.ChatService;
|
||||||
|
import com.rax.vital.util.DatabaseNameUtil;
|
||||||
import org.bson.Document;
|
import org.bson.Document;
|
||||||
|
import org.checkerframework.checker.units.qual.A;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.cloud.context.config.annotation.RefreshScope;
|
import org.springframework.cloud.context.config.annotation.RefreshScope;
|
||||||
|
@ -21,6 +28,9 @@ public class ChatServiceImpl implements ChatService {
|
||||||
@Autowired
|
@Autowired
|
||||||
private SimpMessagingTemplate simpMessagingTemplate;
|
private SimpMessagingTemplate simpMessagingTemplate;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private RemoteUserService remoteUserService;
|
||||||
|
|
||||||
private static final Map<String, MongoDBSource> datasourceMap = new HashMap<>(100);
|
private static final Map<String, MongoDBSource> datasourceMap = new HashMap<>(100);
|
||||||
|
|
||||||
// MongoDB的地址
|
// MongoDB的地址
|
||||||
|
@ -36,24 +46,38 @@ public class ChatServiceImpl implements ChatService {
|
||||||
private String mongoPassword;
|
private String mongoPassword;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sendMessage(String db, String username, String simpSessionId, String msg) {
|
public void sendMessage(String username, String patientName, String idNum, String date, String simpSessionId, String msg) {
|
||||||
MongoDBSource mongoDBSource = datasourceMap.get(simpSessionId);
|
MongoDBSource mongoDBSource = datasourceMap.get(simpSessionId);
|
||||||
if (mongoDBSource == null) {
|
if (mongoDBSource == null) {
|
||||||
mongoDBSource = new MongoDBSource(mongoDBHost, mongoPassword, mongoUsername, db);
|
String databaseName = DatabaseNameUtil.encrypt(patientName) + "_" + DatabaseNameUtil.encrypt(idNum) + "_" + date;
|
||||||
|
mongoDBSource = new MongoDBSource(mongoDBHost, mongoPassword, mongoUsername, databaseName);
|
||||||
datasourceMap.put(simpSessionId, mongoDBSource);
|
datasourceMap.put(simpSessionId, mongoDBSource);
|
||||||
mongoDBSource.open();
|
mongoDBSource.open();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
UserDTO userDTO = new UserDTO();
|
||||||
|
userDTO.setUsername(username);
|
||||||
|
R<UserInfo> info = remoteUserService.info(userDTO, SecurityConstants.FROM_IN);
|
||||||
|
UserInfo userInfo = info.getData();
|
||||||
|
|
||||||
|
Map param = new HashMap();
|
||||||
|
|
||||||
MongoTemplate template = mongoDBSource.getTemplate();
|
MongoTemplate template = mongoDBSource.getTemplate();
|
||||||
Document document = new Document();
|
Document document = new Document();
|
||||||
document.put("content", msg);
|
document.put("content", msg);
|
||||||
document.put("create_time", DateUtil.now());
|
param.put("content", msg);
|
||||||
|
String now = DateUtil.now();
|
||||||
|
document.put("create_time", now);
|
||||||
|
param.put("createTime", now);
|
||||||
document.put("create_user", username);
|
document.put("create_user", username);
|
||||||
|
String name = userInfo.getSysUser().getName();
|
||||||
|
document.put("create_name", name);
|
||||||
|
param.put("createName", name);
|
||||||
document.put("deleted", 0);
|
document.put("deleted", 0);
|
||||||
document.put("revoked", 0);
|
document.put("revoked", 0);
|
||||||
template.insert(document, "t_chat");
|
template.insert(document, "t_chat");
|
||||||
|
|
||||||
simpMessagingTemplate.convertAndSendToUser(db, "/chatroomMessage", document);
|
simpMessagingTemplate.convertAndSendToUser(patientName + idNum + date, "/chatroomMessage", param);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in New Issue
Block a user