mirror of
https://github.com/WeiYe-Jing/datax-web.git
synced 2026-07-03 21:08:58 +08:00
add: 增加获取所有可用表名方法,只取表名
This commit is contained in:
parent
65a63aa086
commit
e775f45148
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@ -52,4 +52,12 @@ public interface QueryToolInterface {
|
||||
* @return2
|
||||
*/
|
||||
public List<String> getColumnNames(String tableName);
|
||||
|
||||
|
||||
/**
|
||||
* 获取所有可用表名
|
||||
*
|
||||
* @return2
|
||||
*/
|
||||
public List<String> getTableNames();
|
||||
}
|
||||
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user