From 12e563fc7a2eb391fec3bb989f189f256de7919d Mon Sep 17 00:00:00 2001 From: Suomm <1474983351@qq.com> Date: Wed, 21 Jun 2023 22:16:54 +0800 Subject: [PATCH] =?UTF-8?q?style:=20=E6=B7=BB=E5=8A=A0=20Generator=20?= =?UTF-8?q?=E6=B3=A8=E9=87=8A=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/mybatisflex/codegen/Generator.java | 38 +++++++++---------- 1 file changed, 18 insertions(+), 20 deletions(-) diff --git a/mybatis-flex-codegen/src/main/java/com/mybatisflex/codegen/Generator.java b/mybatis-flex-codegen/src/main/java/com/mybatisflex/codegen/Generator.java index 34e79d39..1b2c2d41 100644 --- a/mybatis-flex-codegen/src/main/java/com/mybatisflex/codegen/Generator.java +++ b/mybatis-flex-codegen/src/main/java/com/mybatisflex/codegen/Generator.java @@ -1,17 +1,17 @@ -/** - * Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com). - *

- * 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 - *

- * http://www.apache.org/licenses/LICENSE-2.0 - *

- * 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). + *

+ * 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 + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * 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 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"}); } } + }