|
@@ -11,6 +11,7 @@ import com.customer.service.ICustomerService;
|
|
import com.customer.service.IDataSourceService;
|
|
import com.customer.service.IDataSourceService;
|
|
import com.customer.service.ITableInfoService;
|
|
import com.customer.service.ITableInfoService;
|
|
import com.customer.vo.TableInfoVO;
|
|
import com.customer.vo.TableInfoVO;
|
|
|
|
+import org.apache.ibatis.session.RowBounds;
|
|
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.data.redis.core.RedisTemplate;
|
|
import org.springframework.data.redis.core.RedisTemplate;
|
|
@@ -112,19 +113,22 @@ public class TableInfoServiceImpl implements ITableInfoService {
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public List<TableInfoVO> tableInfoList() {
|
|
|
|
|
|
+ public List<TableInfoVO> tableInfoList(Map<String,Object> map) {
|
|
|
|
+ int pageNum = (int)map.get("pageNum");
|
|
|
|
+ int pageSize = (int)map.get("pageSize");
|
|
|
|
+
|
|
//获取数据源信息
|
|
//获取数据源信息
|
|
if(redisTemplate.hasKey("DataSource")){
|
|
if(redisTemplate.hasKey("DataSource")){
|
|
DataSource dataSource =JSON.parseObject(redisTemplate.opsForValue().get("DataSource").toString(),DataSource.class);
|
|
DataSource dataSource =JSON.parseObject(redisTemplate.opsForValue().get("DataSource").toString(),DataSource.class);
|
|
if(dataSource.getDatabaseType().equals(DataSourceType.MYSQL.getDataSourceName())){
|
|
if(dataSource.getDatabaseType().equals(DataSourceType.MYSQL.getDataSourceName())){
|
|
- return tableInfoMapper.tableInfoList(dataSource.getDatabaseName());
|
|
|
|
|
|
+ return tableInfoMapper.tableInfoList(dataSource.getDatabaseName(),map,new RowBounds(pageNum,pageSize));
|
|
}else if(dataSource.getDatabaseType().equals(DataSourceType.SQLSERVER.getDataSourceName())){
|
|
}else if(dataSource.getDatabaseType().equals(DataSourceType.SQLSERVER.getDataSourceName())){
|
|
return tableInfoMapper.sqlServerTableInfoList(dataSource.getDatabaseName());
|
|
return tableInfoMapper.sqlServerTableInfoList(dataSource.getDatabaseName());
|
|
}else if(dataSource.getDatabaseType().equals(DataSourceType.DM.getDataSourceName())){
|
|
}else if(dataSource.getDatabaseType().equals(DataSourceType.DM.getDataSourceName())){
|
|
return tableInfoMapper.dmTableInfoList(dataSource.getDatabaseName());
|
|
return tableInfoMapper.dmTableInfoList(dataSource.getDatabaseName());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- return tableInfoMapper.tableInfoList(url.substring(url.lastIndexOf("/") + 1));
|
|
|
|
|
|
+ return tableInfoMapper.tableInfoList(url.substring(url.lastIndexOf("/") + 1),map,new RowBounds(pageNum,pageSize));
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
@@ -139,13 +143,17 @@ public class TableInfoServiceImpl implements ITableInfoService {
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public List<TableInfo> mysqlTableFieldInfo(String dataBaseName, String tableName) {
|
|
|
|
|
|
+ public List<TableInfo> mysqlTableFieldInfo(String tableName) {
|
|
|
|
+ String dataBaseName = url.substring(url.lastIndexOf("/") + 1);
|
|
|
|
+ if(redisTemplate.hasKey("DataSource")){
|
|
|
|
+ DataSource dataSource =JSON.parseObject(redisTemplate.opsForValue().get("DataSource").toString(),DataSource.class);
|
|
|
|
+ return tableInfoMapper.mysqlTableFieldInfo(dataSource.getDatabaseName(),tableName);
|
|
|
|
+ }
|
|
return tableInfoMapper.mysqlTableFieldInfo(dataBaseName,tableName);
|
|
return tableInfoMapper.mysqlTableFieldInfo(dataBaseName,tableName);
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public void updateMysqlTable(Map<String, Object> map) {
|
|
public void updateMysqlTable(Map<String, Object> map) {
|
|
- String dataBaseName = (String) map.get("dataBaseName");
|
|
|
|
String tableName = (String) map.get("tableName");
|
|
String tableName = (String) map.get("tableName");
|
|
List<TableInfo> filedList = JSON.parseArray(JSON.toJSONString(map.get("field")), TableInfo.class);
|
|
List<TableInfo> filedList = JSON.parseArray(JSON.toJSONString(map.get("field")), TableInfo.class);
|
|
List<String> list= filedList.stream().map(filed->{
|
|
List<String> list= filedList.stream().map(filed->{
|
|
@@ -164,7 +172,15 @@ public class TableInfoServiceImpl implements ITableInfoService {
|
|
stringBuilder.append("COMMENT '"+filed.getFieldDescription()+"'");
|
|
stringBuilder.append("COMMENT '"+filed.getFieldDescription()+"'");
|
|
return stringBuilder.toString();
|
|
return stringBuilder.toString();
|
|
}).collect(Collectors.toList());
|
|
}).collect(Collectors.toList());
|
|
- tableInfoMapper.updateMysqlTable(dataBaseName,tableName,list);
|
|
|
|
|
|
+
|
|
|
|
+ if(redisTemplate.hasKey("DataSource")){
|
|
|
|
+ DataSource dataSource =JSON.parseObject(redisTemplate.opsForValue().get("DataSource").toString(),DataSource.class);
|
|
|
|
+ tableInfoMapper.updateMysqlTable(dataSource.getDatabaseName(),tableName,list);
|
|
|
|
+ }else {
|
|
|
|
+ String dataBaseName = url.substring(url.lastIndexOf("/") + 1);
|
|
|
|
+ tableInfoMapper.updateMysqlTable(dataBaseName,tableName,list);
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|