add: 增加获取所有可用表名方法,只取表名

This commit is contained in:
zhouhongfa 2019-07-31 21:08:15 +08:00
parent 65a63aa086
commit e775f45148
3 changed files with 28 additions and 0 deletions

View File

@ -275,4 +275,18 @@ public abstract class BaseQueryTool implements QueryToolInterface {
}
return columns;
}
@Override
public List<String> getTableNames() {
List<String> res = Lists.newArrayList();
List<Map<String, Object>> tables = getTables();
//这里只取表名
tables.forEach(e -> {
//表名注释
List tValues = new ArrayList(e.values());
//第一个总是表名
res.add((String) tValues.get(0));
});
return res;
}
}

View File

@ -52,4 +52,12 @@ public interface QueryToolInterface {
* @return2
*/
public List<String> getColumnNames(String tableName);
/**
* 获取所有可用表名
*
* @return2
*/
public List<String> getTableNames();
}

View File

@ -55,4 +55,10 @@ public class MySQLQueryToolTest {
List<String> columns = queryTool.getColumnNames("datax_plugin");
log.info(columns.toString());
}
@Test
public void getTableNames() {
List<String> tableNames = queryTool.getTableNames();
tableNames.forEach(System.out::println);
}
}