feat: 更新代码生成功能-二阶段

This commit is contained in:
l90215
2025-07-22 18:50:37 +08:00
parent 8b3c0b4134
commit ffe4867d40
5 changed files with 43 additions and 18 deletions

View File

@@ -78,4 +78,28 @@ public class DataBaseHelper {
public static List<String> getDataSourceNameList() {
return new ArrayList<>(DS.getDataSources().keySet());
}
/**
* 获取当前连接的所有表名称
*/
public static List<String> getCurrentDataSourceTableNameList() {
DataSource dataSource = DS.determineDataSource();
List<String> tableNames = new ArrayList<>();
try (Connection conn = dataSource.getConnection()) {
DatabaseMetaData metaData = conn.getMetaData();
String catalog = conn.getCatalog();
String schema = conn.getSchema();
// 获取所有表名
try (var resultSet = metaData.getTables(catalog, schema, "%", new String[]{"TABLE"})) {
while (resultSet.next()) {
String tableName = resultSet.getString("TABLE_NAME");
tableNames.add(tableName);
}
}
} catch (SQLException e) {
throw new ServiceException("获取表名称失败: " + e.getMessage());
}
return tableNames;
}
}