|
@@ -3,13 +3,17 @@ package com.customer.service.impl;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.customer.config.DynamicDataSource;
|
|
|
import com.customer.config.GenConfig;
|
|
|
+import com.customer.constant.DataSourceType;
|
|
|
import com.customer.mapper.TableInfoMapper;
|
|
|
+import com.customer.pojo.DataSource;
|
|
|
import com.customer.pojo.TableInfo;
|
|
|
import com.customer.service.ICustomerService;
|
|
|
import com.customer.service.IDataSourceService;
|
|
|
import com.customer.service.ITableInfoService;
|
|
|
import com.customer.vo.TableInfoVO;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
+import org.springframework.data.redis.core.RedisTemplate;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.util.StringUtils;
|
|
@@ -27,6 +31,12 @@ public class TableInfoServiceImpl implements ITableInfoService {
|
|
|
@Resource
|
|
|
private TableInfoMapper tableInfoMapper;
|
|
|
|
|
|
+ @Resource
|
|
|
+ private RedisTemplate redisTemplate;
|
|
|
+
|
|
|
+ @Value("${spring.datasource.dynamic.datasource.master.url}")
|
|
|
+ private String url;
|
|
|
+
|
|
|
@Override
|
|
|
@Transactional
|
|
|
public void createMysqlDataBase(Map<String, Object> map) {
|
|
@@ -102,8 +112,20 @@ public class TableInfoServiceImpl implements ITableInfoService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public List<TableInfoVO> tableInfoList(String databaseName) {
|
|
|
- return tableInfoMapper.tableInfoList(databaseName);
|
|
|
+ public List<TableInfoVO> tableInfoList() {
|
|
|
+ //获取数据源信息
|
|
|
+ if(redisTemplate.hasKey("DataSource")){
|
|
|
+ DataSource dataSource =JSON.parseObject(redisTemplate.opsForValue().get("DataSource").toString(),DataSource.class);
|
|
|
+ if(dataSource.getDatabaseType().equals(DataSourceType.MYSQL.getDataSourceName())){
|
|
|
+ return tableInfoMapper.tableInfoList(dataSource.getDatabaseName());
|
|
|
+ }else if(dataSource.getDatabaseType().equals(DataSourceType.SQLSERVER.getDataSourceName())){
|
|
|
+ return tableInfoMapper.sqlServerTableInfoList(dataSource.getDatabaseName());
|
|
|
+ }else if(dataSource.getDatabaseType().equals(DataSourceType.DM.getDataSourceName())){
|
|
|
+ return tableInfoMapper.dmTableInfoList(dataSource.getDatabaseName());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return tableInfoMapper.tableInfoList(url.substring(url.lastIndexOf("/") + 1));
|
|
|
+
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -154,10 +176,10 @@ public class TableInfoServiceImpl implements ITableInfoService {
|
|
|
return tableInfoMapper.sqlServerTableExist(stringBuilder.toString());
|
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
- public List<TableInfoVO> sqlServerTableInfoList() {
|
|
|
- return tableInfoMapper.sqlServerTableInfoList();
|
|
|
- }
|
|
|
+// @Override
|
|
|
+// public List<TableInfoVO> sqlServerTableInfoList() {
|
|
|
+// return tableInfoMapper.sqlServerTableInfoList();
|
|
|
+// }
|
|
|
|
|
|
@Override
|
|
|
public int selectSqlServerDataCount(String tableName) {
|
|
@@ -205,10 +227,10 @@ public class TableInfoServiceImpl implements ITableInfoService {
|
|
|
tableInfoMapper.updateSqlserverTable(tableName,list,descriptionList);
|
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
- public List<Map<String, Object>> getDataBasesInfo(String DBname) {
|
|
|
- return tableInfoMapper.getDataBasesInfo(DBname);
|
|
|
- }
|
|
|
+// @Override
|
|
|
+// public List<Map<String, Object>> getDataBasesInfo(String DBname) {
|
|
|
+// return tableInfoMapper.getDataBasesInfo(DBname);
|
|
|
+// }
|
|
|
|
|
|
@Override
|
|
|
public int dmTableExist(String dataBaseName, String tableName) {
|