mirror of
https://gitee.com/mybatis-flex/mybatis-flex.git
synced 2025-12-07 00:58:24 +08:00
style: 添加 Generator 注释。
This commit is contained in:
parent
16f607ef28
commit
12e563fc7a
@ -1,17 +1,17 @@
|
||||
/**
|
||||
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
|
||||
* <p>
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* <p>
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* <p>
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
/*
|
||||
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
|
||||
* <p>
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* <p>
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* <p>
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.mybatisflex.codegen;
|
||||
|
||||
@ -31,6 +31,9 @@ import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 代码生成器。
|
||||
*/
|
||||
public class Generator {
|
||||
|
||||
protected DataSource dataSource;
|
||||
@ -40,20 +43,17 @@ public class Generator {
|
||||
protected Connection conn = null;
|
||||
protected DatabaseMetaData dbMeta = null;
|
||||
|
||||
|
||||
public Generator(DataSource dataSource, GlobalConfig globalConfig) {
|
||||
this.dataSource = dataSource;
|
||||
this.globalConfig = globalConfig;
|
||||
}
|
||||
|
||||
|
||||
public Generator(DataSource dataSource, GlobalConfig globalConfig, IDialect dialect) {
|
||||
this.dataSource = dataSource;
|
||||
this.globalConfig = globalConfig;
|
||||
this.dialect = dialect;
|
||||
}
|
||||
|
||||
|
||||
public void generate() {
|
||||
try {
|
||||
conn = dataSource.getConnection();
|
||||
@ -74,7 +74,6 @@ public class Generator {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected void buildPrimaryKey(Table table) throws SQLException {
|
||||
try (ResultSet rs = dbMeta.getPrimaryKeys(conn.getCatalog(), null, table.getName())) {
|
||||
while (rs.next()) {
|
||||
@ -84,7 +83,6 @@ public class Generator {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private List<Table> buildTables() throws SQLException {
|
||||
StrategyConfig strategyConfig = globalConfig.getStrategyConfig();
|
||||
String schemaName = strategyConfig.getGenerateSchema();
|
||||
@ -117,7 +115,6 @@ public class Generator {
|
||||
return tables;
|
||||
}
|
||||
|
||||
|
||||
protected ResultSet getTablesResultSet(String schema) throws SQLException {
|
||||
if (globalConfig.getStrategyConfig().isGenerateForView()) {
|
||||
return dialect.getTablesResultSet(dbMeta, conn, schema, new String[]{"TABLE", "VIEW"});
|
||||
@ -125,4 +122,5 @@ public class Generator {
|
||||
return dialect.getTablesResultSet(dbMeta, conn, schema, new String[]{"TABLE"});
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user