|
|
@@ -54,16 +54,21 @@ public class DataBasesService {
|
|
|
BeanUtils.copyProperties(databasesInfo, databases);
|
|
|
//校验此连接是否可用
|
|
|
implementSqlService.connectTest(databases);
|
|
|
+ LOGGER.info("校验此连接是否可用完成...");
|
|
|
+
|
|
|
String note = databases.getNote();
|
|
|
if (note == null || "".equals(note)){
|
|
|
note = "";
|
|
|
databases.setNote(note);
|
|
|
}
|
|
|
dataConnectorMapper.inputDataBases(databases);
|
|
|
+ LOGGER.info("执行完保存数据源操作...");
|
|
|
int id = databases.getId();
|
|
|
databasesInfo.setId(id);
|
|
|
//添加数据源可切换
|
|
|
addDataSource(databasesInfo);
|
|
|
+
|
|
|
+ LOGGER.info("返回RepEntity,data={}", id);
|
|
|
return new RepEntity(RepCode.success,id);
|
|
|
}
|
|
|
|
|
|
@@ -204,6 +209,8 @@ public class DataBasesService {
|
|
|
if (target.size() == 0) {
|
|
|
target.putAll(dataSourceRegister.getSlaveDataSources());
|
|
|
}
|
|
|
+ LOGGER.info("target={}", target);
|
|
|
+ LOGGER.info("target contains Key {} = {}", databasesInfo.getId(), target.containsKey(String.valueOf(databasesInfo.getId())));
|
|
|
if (!target.containsKey(String.valueOf(databasesInfo.getId()))) {
|
|
|
target.put(databasesInfo.getId(), dataSourceRegister.buildDataSource(dsMap));
|
|
|
DynamicDataSource datasource = (DynamicDataSource) ContextUtil.getBean("dataSource");
|
|
|
@@ -211,7 +218,11 @@ public class DataBasesService {
|
|
|
datasource.afterPropertiesSet();
|
|
|
|
|
|
Set<String> dataSourceIds = DynamicDataSourceContextHolder.getDataSourceIds();
|
|
|
+ LOGGER.info("before add,dataSourceIds={}", dataSourceIds);
|
|
|
+
|
|
|
dataSourceIds.add(String.valueOf(databasesInfo.getId()));
|
|
|
+ LOGGER.info("after add,dataSourceIds={}", dataSourceIds);
|
|
|
+
|
|
|
DynamicDataSourceContextHolder.setDataSourceIds(dataSourceIds);
|
|
|
}
|
|
|
}
|