style(): 修改代码格式
parent
d24a344ac4
commit
1e1797f443
|
@ -233,12 +233,13 @@ public class DataSourceServiceImpl extends ServiceImpl<DataSourceMapper, DataSou
|
|||
if ("mysql".equals(dataType.getDataType())) {
|
||||
driveClass = dataType.getDriverManager();
|
||||
jdbcUrl = dataType.getJdbcPre() + dataSource.getDataSourceIp() + ":" + dataSource.getDataSourcePort() + "/" + dataSource.getDataSourceDatabaseName() + "?" + dataSource.getAdditionalConfiguration();
|
||||
String tableSQL = "select * from information_schema.tables where TABLE_SCHEMA = " + "'" + dataSource.getDataSourceDatabaseName() + "'";
|
||||
// 加载数据库驱动
|
||||
Class.forName(driveClass);
|
||||
// 连接数据库
|
||||
Connection conn = DriverManager.getConnection(jdbcUrl, dataSource.getDataSourceUsername(), dataSource.getDataSourcePassword());
|
||||
Statement st = conn.createStatement();
|
||||
ResultSet rs = st.executeQuery("select * from information_schema.tables where TABLE_SCHEMA = " + "'" + dataSource.getDataSourceDatabaseName() + "'");
|
||||
ResultSet rs = st.executeQuery(tableSQL);
|
||||
while (rs.next()) {
|
||||
// 获取表名
|
||||
String tableName = rs.getString("TABLE_NAME");
|
||||
|
@ -247,16 +248,17 @@ public class DataSourceServiceImpl extends ServiceImpl<DataSourceMapper, DataSou
|
|||
// 添加数据
|
||||
// 表数据数量
|
||||
assetStructureTableList.add(
|
||||
new AssetStructureTable() {{
|
||||
setAssetStructureId(entity.getId());
|
||||
setTableName(tableName);
|
||||
setTableNameAnnotation(tableNameAnnotation);
|
||||
}}
|
||||
AssetStructureTable.builder()
|
||||
.assetStructureId(entity.getId())
|
||||
.tableName(tableName)
|
||||
.tableNameAnnotation(tableNameAnnotation)
|
||||
.build()
|
||||
);
|
||||
}
|
||||
assetStructureTableList.stream().forEach(assetStructureTable -> {
|
||||
String tableDataCountSQL = "select count(*) as countNum from " + assetStructureTable.getTableName();
|
||||
try {
|
||||
ResultSet rs2 = st.executeQuery("select count(*) as countNum from " + assetStructureTable.getTableName());
|
||||
ResultSet rs2 = st.executeQuery(tableDataCountSQL);
|
||||
while (rs2.next()) {
|
||||
assetStructureTable.setTableDataCount(rs2.getLong("countNum"));
|
||||
}
|
||||
|
@ -291,13 +293,14 @@ public class DataSourceServiceImpl extends ServiceImpl<DataSourceMapper, DataSou
|
|||
}
|
||||
rs4.close();
|
||||
|
||||
String dataDetailsSQL = "select * from " + assetStructureTable.getTableName() + " where 1=2";
|
||||
// 字段类型
|
||||
String typeName = rs3.getString("TYPE_NAME");
|
||||
|
||||
// 映射类型
|
||||
String mappingType = null;
|
||||
|
||||
PreparedStatement st1 = conn.prepareStatement("select * from " + assetStructureTable.getTableName() + " where 1=2");
|
||||
PreparedStatement st1 = conn.prepareStatement(dataDetailsSQL);
|
||||
ResultSetMetaData rsmd = st1.executeQuery().getMetaData();
|
||||
for (int i = 0; i < rsmd.getColumnCount(); i++) {
|
||||
if (columnName.equals(rsmd.getColumnName(i + 1))) {
|
||||
|
@ -320,19 +323,19 @@ public class DataSourceServiceImpl extends ServiceImpl<DataSourceMapper, DataSou
|
|||
boolean finalIsPrimaryKey = isPrimaryKey;
|
||||
String finalMappingType = mappingType;
|
||||
assetTableDetails.add(
|
||||
new AssetTableDetails() {{
|
||||
setAssetStructureTableId(assetStructureTable.getId());
|
||||
setName(columnName);
|
||||
setAnnotation(remarks);
|
||||
setPrimaryOrNot(finalIsPrimaryKey ? "Y" : "N");
|
||||
setType(typeName);
|
||||
setMappingType(finalMappingType);
|
||||
setLength((long) columnSize);
|
||||
setDecimalPoint((long) decimalDigits);
|
||||
setNullOrNot(isNullable ? "Y" : "N");
|
||||
setDefaultValue(defaultValue);
|
||||
setYesNoDictionary(null);
|
||||
}}
|
||||
AssetTableDetails.builder()
|
||||
.assetStructureTableId(assetStructureTable.getId())
|
||||
.name(columnName)
|
||||
.annotation(remarks)
|
||||
.primaryOrNot(finalIsPrimaryKey ? "Y" : "N")
|
||||
.type(typeName)
|
||||
.mappingType(finalMappingType)
|
||||
.length((long) columnSize)
|
||||
.decimalPoint((long) decimalDigits)
|
||||
.nullOrNot(isNullable ? "Y" : "N")
|
||||
.defaultValue(defaultValue)
|
||||
.yesNoDictionary(null)
|
||||
.build()
|
||||
);
|
||||
}
|
||||
rs3.close();
|
||||
|
@ -408,12 +411,13 @@ public class DataSourceServiceImpl extends ServiceImpl<DataSourceMapper, DataSou
|
|||
if ("mysql".equals(dataType.getDataType())) {
|
||||
driveClass = dataType.getDriverManager();
|
||||
jdbcUrl = dataType.getJdbcPre() + dataSource.getDataSourceIp() + ":" + dataSource.getDataSourcePort() + "/" + dataSource.getDataSourceDatabaseName() + "?" + dataSource.getAdditionalConfiguration();
|
||||
String tableSQL = "select * from information_schema.tables where TABLE_SCHEMA = " + "'" + dataSource.getDataSourceDatabaseName() + "'";
|
||||
// 加载数据库驱动
|
||||
Class.forName(driveClass);
|
||||
// 连接数据库
|
||||
Connection conn = DriverManager.getConnection(jdbcUrl, dataSource.getDataSourceUsername(), dataSource.getDataSourcePassword());
|
||||
Statement st = conn.createStatement();
|
||||
ResultSet rs = st.executeQuery("select * from information_schema.tables where TABLE_SCHEMA = " + "'" + dataSource.getDataSourceDatabaseName() + "'");
|
||||
ResultSet rs = st.executeQuery(tableSQL);
|
||||
while (rs.next()) {
|
||||
// 获取表名
|
||||
String tableName = rs.getString("TABLE_NAME");
|
||||
|
@ -422,16 +426,17 @@ public class DataSourceServiceImpl extends ServiceImpl<DataSourceMapper, DataSou
|
|||
// 添加数据
|
||||
// 表数据数量
|
||||
assetStructureTableList.add(
|
||||
new AssetStructureTable() {{
|
||||
setAssetStructureId(entity.getId());
|
||||
setTableName(tableName);
|
||||
setTableNameAnnotation(tableNameAnnotation);
|
||||
}}
|
||||
AssetStructureTable.builder()
|
||||
.assetStructureId(entity.getId())
|
||||
.tableName(tableName)
|
||||
.tableNameAnnotation(tableNameAnnotation)
|
||||
.build()
|
||||
);
|
||||
}
|
||||
assetStructureTableList.stream().forEach(assetStructureTable -> {
|
||||
String tableDataCountSQL = "select count(*) as countNum from " + assetStructureTable.getTableName();
|
||||
try {
|
||||
ResultSet rs2 = st.executeQuery("select count(*) as countNum from " + assetStructureTable.getTableName());
|
||||
ResultSet rs2 = st.executeQuery(tableDataCountSQL);
|
||||
while (rs2.next()) {
|
||||
assetStructureTable.setTableDataCount(rs2.getLong("countNum"));
|
||||
}
|
||||
|
@ -473,13 +478,15 @@ public class DataSourceServiceImpl extends ServiceImpl<DataSourceMapper, DataSou
|
|||
}
|
||||
rs4.close();
|
||||
|
||||
String dataDetailsSQL = "select * from " + assetStructureTable.getTableName() + " where 1=2";
|
||||
|
||||
// 字段类型
|
||||
String typeName = rs3.getString("TYPE_NAME");
|
||||
|
||||
// 映射类型
|
||||
String mappingType = null;
|
||||
|
||||
PreparedStatement st1 = conn.prepareStatement("select * from " + assetStructureTable.getTableName() + " where 1=2");
|
||||
PreparedStatement st1 = conn.prepareStatement(dataDetailsSQL);
|
||||
ResultSetMetaData rsmd = st1.executeQuery().getMetaData();
|
||||
for (int i = 0; i < rsmd.getColumnCount(); i++) {
|
||||
if (columnName.equals(rsmd.getColumnName(i + 1))) {
|
||||
|
@ -502,19 +509,19 @@ public class DataSourceServiceImpl extends ServiceImpl<DataSourceMapper, DataSou
|
|||
boolean finalIsPrimaryKey = isPrimaryKey;
|
||||
String finalMappingType = mappingType;
|
||||
assetTableDetails.add(
|
||||
new AssetTableDetails() {{
|
||||
setAssetStructureTableId(assetStructureTable.getId());
|
||||
setName(columnName);
|
||||
setAnnotation(remarks);
|
||||
setPrimaryOrNot(finalIsPrimaryKey ? "Y" : "N");
|
||||
setType(typeName);
|
||||
setMappingType(finalMappingType);
|
||||
setLength((long) columnSize);
|
||||
setDecimalPoint((long) decimalDigits);
|
||||
setNullOrNot(isNullable ? "Y" : "N");
|
||||
setDefaultValue(defaultValue);
|
||||
setYesNoDictionary(null);
|
||||
}}
|
||||
AssetTableDetails.builder()
|
||||
.assetStructureTableId(assetStructureTable.getId())
|
||||
.name(columnName)
|
||||
.annotation(remarks)
|
||||
.primaryOrNot(finalIsPrimaryKey ? "Y" : "N")
|
||||
.type(typeName)
|
||||
.mappingType(finalMappingType)
|
||||
.length((long) columnSize)
|
||||
.decimalPoint((long) decimalDigits)
|
||||
.nullOrNot(isNullable ? "Y" : "N")
|
||||
.defaultValue(defaultValue)
|
||||
.yesNoDictionary(null)
|
||||
.build()
|
||||
);
|
||||
}
|
||||
rs3.close();
|
||||
|
|
|
@ -46,10 +46,10 @@ public class AssetStructureServiceImpl extends ServiceImpl<AssetStructureMapper,
|
|||
|
||||
assetStructureTableDataCount = assetStructureTableList.stream().mapToLong(AssetStructureTable::getTableDataCount).sum();
|
||||
|
||||
return new AssetStructureResp(){{
|
||||
setAssetStructureList(assetStructureList);
|
||||
setAssetStructureTableCount(assetStructureTableCount);
|
||||
setAssetStructureTableDataCount(assetStructureTableDataCount);
|
||||
}};
|
||||
return AssetStructureResp.builder()
|
||||
.assetStructureList(assetStructureList)
|
||||
.assetStructureTableCount(assetStructureTableCount)
|
||||
.assetStructureTableDataCount(assetStructureTableDataCount)
|
||||
.build();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,9 +18,10 @@ import java.util.List;
|
|||
* @CreateTime: 2024/4/22 下午5:22
|
||||
*/
|
||||
@Service
|
||||
public class AssetStructureTableServiceImpl extends ServiceImpl<AssetStructureTableMapper, AssetStructureTable> implements IAssetStructureTableService {
|
||||
public class AssetStructureTableServiceImpl extends ServiceImpl<AssetStructureTableMapper, AssetStructureTable> implements IAssetStructureTableService {
|
||||
/**
|
||||
* 查询该数据资产表
|
||||
*
|
||||
* @param assetStructureId 数据资产id
|
||||
* @return
|
||||
*/
|
||||
|
@ -34,10 +35,10 @@ public class AssetStructureTableServiceImpl extends ServiceImpl<AssetStructureT
|
|||
long tableCount = assetStructureTableList.size();
|
||||
long tableDataCount = assetStructureTableList.stream().mapToLong(AssetStructureTable::getTableDataCount).sum();
|
||||
|
||||
return new AssetStructureTableResp(){{
|
||||
setAssetStructureList(assetStructureTableList);
|
||||
setTableCount(tableCount);
|
||||
setTableDataCount(tableDataCount);;
|
||||
}};
|
||||
return AssetStructureTableResp.builder()
|
||||
.assetStructureList(assetStructureTableList)
|
||||
.tableCount(tableCount)
|
||||
.tableDataCount(tableDataCount)
|
||||
.build();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue