|
@@ -56,19 +56,15 @@ public class DynamicDataSourceHandler extends HandlerInterceptorAdapter {
|
|
|
if (StringUtils.containsAny(requestURI, IGNORE_URL)) {
|
|
|
return true;
|
|
|
}
|
|
|
- for (String url : notUrlList) {
|
|
|
- if(requestURI.contains(url)) {
|
|
|
- return true;
|
|
|
- }
|
|
|
- }
|
|
|
- resetDataSource();
|
|
|
+ resetDataSource(request);
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 多租户处理,数据源切换
|
|
|
+ * @param request
|
|
|
*/
|
|
|
- public void resetDataSource() {
|
|
|
+ public void resetDataSource(HttpServletRequest request) {
|
|
|
// 是否启用多数据源
|
|
|
boolean isDynamic = SpringHelper.getBoolean("spring.datasource.dynamic.enabled", false);
|
|
|
if (!isDynamic) {
|
|
@@ -80,7 +76,6 @@ public class DynamicDataSourceHandler extends HandlerInterceptorAdapter {
|
|
|
if(StringUtils.isNotBlank(dynamicDbName)) {
|
|
|
dbNameDefault=dynamicDbName;
|
|
|
}
|
|
|
-
|
|
|
// 将应用名中的中划线替换为下划线,按照公司要求应用名统一用中划线,数据库名统一用下划线
|
|
|
dbNameDefault = dbNameDefault.replace("-", "_");
|
|
|
String newDsName = dbNameDefault;
|
|
@@ -88,7 +83,15 @@ public class DynamicDataSourceHandler extends HandlerInterceptorAdapter {
|
|
|
// 创建的数据源名称: 集团编码_应用名
|
|
|
newDsName = PoemsContext.getContext().getGroupCode() + "_" + newDsName;
|
|
|
}
|
|
|
-
|
|
|
+ /**
|
|
|
+ * 判断如果如果是DMP-ALARM 请求的路径就切换到默认的数据库
|
|
|
+ */
|
|
|
+ for (String url : notUrlList) {
|
|
|
+ if(request.getRequestURI().contains(url)) {
|
|
|
+ newDsName =dbNameDefault;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
// 数据源中是否已存在
|
|
|
if (!dataSource.getCurrentDataSources().containsKey(newDsName)) {
|
|
|
// 设置新数据源
|