mirror of
https://gitee.com/dromara/dbswitch.git
synced 2025-10-17 07:03:54 +00:00
代码简单调整
This commit is contained in:
@@ -9,8 +9,10 @@
|
|||||||
/////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////
|
||||||
package com.gitee.dbswitch.common.type;
|
package com.gitee.dbswitch.common.type;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 处理大小写转换的枚举类
|
* 处理名称转换的枚举类
|
||||||
*
|
*
|
||||||
* @author tang
|
* @author tang
|
||||||
*/
|
*/
|
||||||
@@ -30,33 +32,11 @@ public enum CaseConvertEnum {
|
|||||||
/**
|
/**
|
||||||
* 驼峰转下划线
|
* 驼峰转下划线
|
||||||
*/
|
*/
|
||||||
SNAKE(s -> {
|
SNAKE(StrUtil::toUnderlineCase),
|
||||||
StringBuilder snakeCaseString = new StringBuilder(s);
|
|
||||||
for (int i = 1; i < snakeCaseString.length(); i++) {
|
|
||||||
if (Character.isUpperCase(snakeCaseString.charAt(i))) {
|
|
||||||
snakeCaseString.insert(i, '_');
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return snakeCaseString.toString().toLowerCase();
|
|
||||||
}),
|
|
||||||
/**
|
/**
|
||||||
* 下划线转驼峰
|
* 下划线转驼峰
|
||||||
*/
|
*/
|
||||||
CAMEL(s -> {
|
CAMEL(StrUtil::toCamelCase);
|
||||||
String[] parts = s.split("_");
|
|
||||||
StringBuilder camelCaseString = new StringBuilder();
|
|
||||||
for (int i = 0; i < parts.length; i++) {
|
|
||||||
String part = parts[i];
|
|
||||||
if (i == 0) {
|
|
||||||
camelCaseString.append(part.toLowerCase()); // 第一个单词保持全小写
|
|
||||||
} else {
|
|
||||||
camelCaseString.append(Character.toUpperCase(part.charAt(0))); // 其他单词首字母大写
|
|
||||||
camelCaseString.append(part.substring(1).toLowerCase()); // 其他部分小写
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return camelCaseString.toString();
|
|
||||||
});
|
|
||||||
|
|
||||||
private Converter function;
|
private Converter function;
|
||||||
|
|
||||||
|
@@ -69,8 +69,7 @@ public class PostgresMetadataQueryProvider extends AbstractMetadataProvider {
|
|||||||
@Override
|
@Override
|
||||||
public List<TableDescription> queryTableList(Connection connection, String schemaName) {
|
public List<TableDescription> queryTableList(Connection connection, String schemaName) {
|
||||||
List<TableDescription> tableList = super.queryTableList(connection, schemaName);
|
List<TableDescription> tableList = super.queryTableList(connection, schemaName);
|
||||||
Set<String> partitionedTable = getPartitionedTable(connection, schemaName,
|
Set<String> partitionedTable = getPartitionedTable(connection, schemaName);
|
||||||
SHOW_SUB_PARTITIONED_TABLE);
|
|
||||||
return tableList.stream().filter(t -> !partitionedTable.contains(t.getTableName()))
|
return tableList.stream().filter(t -> !partitionedTable.contains(t.getTableName()))
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
@@ -277,8 +276,8 @@ public class PostgresMetadataQueryProvider extends AbstractMetadataProvider {
|
|||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Set<String> getPartitionedTable(Connection connection, String schemaName, String sql) {
|
protected Set<String> getPartitionedTable(Connection connection, String schemaName) {
|
||||||
String query = String.format(sql, schemaName);
|
String query = String.format(SHOW_SUB_PARTITIONED_TABLE, schemaName);
|
||||||
Set<String> partitionedTable = new HashSet<>();
|
Set<String> partitionedTable = new HashSet<>();
|
||||||
try (Statement st = connection.createStatement()) {
|
try (Statement st = connection.createStatement()) {
|
||||||
ResultSet resultSet = st.executeQuery(query);
|
ResultSet resultSet = st.executeQuery(query);
|
||||||
|
Reference in New Issue
Block a user