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