This commit is contained in:
开源海哥 2023-08-30 12:34:55 +08:00
commit 4263a6a742

View File

@ -30,6 +30,7 @@ import java.sql.SQLException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.List; import java.util.List;
import java.util.stream.Collectors;
/** /**
* 代码生成器 * 代码生成器
@ -55,11 +56,18 @@ public class Generator {
} }
public void generate() { public void generate() {
try (Connection conn = dataSource.getConnection();) { try (Connection conn = dataSource.getConnection()) {
dbMeta = conn.getMetaData(); dbMeta = conn.getMetaData();
List<Table> tables = buildTables(conn); List<Table> tables = buildTables(conn);
if (tables.isEmpty()) {
System.err.printf("table %s not found.%n", globalConfig.getGenerateTables());
return;
} else {
System.out.printf("find tables: %s%n", tables.stream().map(Table::getName).collect(Collectors.toSet()));
}
for (Table table : tables) { for (Table table : tables) {
Collection<IGenerator> generators = GeneratorFactory.getGenerators(); Collection<IGenerator> generators = GeneratorFactory.getGenerators();
for (IGenerator generator : generators) { for (IGenerator generator : generators) {