mirror of
https://gitee.com/mybatis-flex/mybatis-flex.git
synced 2025-12-08 17:48:25 +08:00
!85 optimize mybatis-flex-codegen javadoc
Merge pull request !85 from 王帅/main
This commit is contained in:
commit
a040d76257
@ -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"});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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.config;
|
package com.mybatisflex.codegen.config;
|
||||||
|
|
||||||
@ -21,30 +21,81 @@ import org.apache.ibatis.type.TypeHandler;
|
|||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 表字段的单独设置。
|
||||||
|
*/
|
||||||
public class ColumnConfig implements Serializable {
|
public class ColumnConfig implements Serializable {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 字段名称。
|
||||||
|
*/
|
||||||
private String columnName;
|
private String columnName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* insert 的时候默认值,这个值会直接被拼接到 sql 而不通过参数设置。
|
||||||
|
*/
|
||||||
private String onInsertValue;
|
private String onInsertValue;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* update 的时候自动赋值,这个值会直接被拼接到 sql 而不通过参数设置。
|
||||||
|
*/
|
||||||
private String onUpdateValue;
|
private String onUpdateValue;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否是大字段,大字段 APT 不会生成到 DEFAULT_COLUMNS 里。
|
||||||
|
*/
|
||||||
private Boolean isLarge;
|
private Boolean isLarge;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否是逻辑删除字段,一张表中只能存在 1 一个逻辑删除字段。
|
||||||
|
*/
|
||||||
private Boolean isLogicDelete;
|
private Boolean isLogicDelete;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否为乐观锁字段。
|
||||||
|
*/
|
||||||
private Boolean version;
|
private Boolean version;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 配置的 jdbcType。
|
||||||
|
*/
|
||||||
private JdbcType jdbcType;
|
private JdbcType jdbcType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 自定义 TypeHandler。
|
||||||
|
*/
|
||||||
private Class<? extends TypeHandler> typeHandler;
|
private Class<? extends TypeHandler> typeHandler;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 脱敏方式。
|
||||||
|
*/
|
||||||
private String mask;
|
private String mask;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 字段是否为主键。
|
||||||
|
*/
|
||||||
private boolean isPrimaryKey = false;
|
private boolean isPrimaryKey = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ID 生成策略。
|
||||||
|
*/
|
||||||
private KeyType keyType;
|
private KeyType keyType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ID 生成器值。
|
||||||
|
*/
|
||||||
private String keyValue;
|
private String keyValue;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* sequence 序列执行顺序。
|
||||||
|
*/
|
||||||
private Boolean keyBefore;
|
private Boolean keyBefore;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否是租户 ID。
|
||||||
|
*/
|
||||||
private Boolean tenantId;
|
private Boolean tenantId;
|
||||||
|
|
||||||
|
|
||||||
public String getColumnName() {
|
public String getColumnName() {
|
||||||
return columnName;
|
return columnName;
|
||||||
}
|
}
|
||||||
@ -156,4 +207,5 @@ public class ColumnConfig implements Serializable {
|
|||||||
public void setTenantId(Boolean tenantId) {
|
public void setTenantId(Boolean tenantId) {
|
||||||
this.tenantId = tenantId;
|
this.tenantId = tenantId;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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.config;
|
package com.mybatisflex.codegen.config;
|
||||||
|
|
||||||
@ -22,35 +22,51 @@ import com.mybatisflex.annotation.UpdateListener;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 表的单独设置。
|
||||||
|
*/
|
||||||
public class TableConfig {
|
public class TableConfig {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 表名。
|
||||||
|
*/
|
||||||
private String tableName;
|
private String tableName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 数据库的 schema(模式)
|
* 数据库的 schema(模式)。
|
||||||
*/
|
*/
|
||||||
private String schema;
|
private String schema;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 默认为 驼峰属性 转换为 下划线字段
|
* 默认为 驼峰属性 转换为 下划线字段。
|
||||||
*/
|
*/
|
||||||
private Boolean camelToUnderline;
|
private Boolean camelToUnderline;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 监听 entity 的 insert 行为。
|
||||||
|
*/
|
||||||
private Class<? extends InsertListener> insertListenerClass;
|
private Class<? extends InsertListener> insertListenerClass;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 监听 entity 的 update 行为。
|
||||||
|
*/
|
||||||
private Class<? extends UpdateListener> updateListenerClass;
|
private Class<? extends UpdateListener> updateListenerClass;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 监听 entity 的查询数据的 set 行为。
|
||||||
|
*/
|
||||||
private Class<? extends SetListener> setListenerClass;
|
private Class<? extends SetListener> setListenerClass;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 对应列的配置。
|
||||||
|
*/
|
||||||
private Map<String, ColumnConfig> columnConfigMap;
|
private Map<String, ColumnConfig> columnConfigMap;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否开启 Mapper 生成。
|
||||||
|
*/
|
||||||
private Boolean mapperGenerateEnable = Boolean.TRUE;
|
private Boolean mapperGenerateEnable = Boolean.TRUE;
|
||||||
|
|
||||||
|
|
||||||
public String getTableName() {
|
public String getTableName() {
|
||||||
return tableName;
|
return tableName;
|
||||||
}
|
}
|
||||||
@ -126,5 +142,4 @@ public class TableConfig {
|
|||||||
return columnConfigMap == null ? null : columnConfigMap.get(columnName);
|
return columnConfigMap == null ? null : columnConfigMap.get(columnName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,20 @@
|
|||||||
|
/*
|
||||||
|
* 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.config;
|
||||||
@ -23,6 +23,9 @@ package com.mybatisflex.codegen.constant;
|
|||||||
*/
|
*/
|
||||||
public class GenTypeConst {
|
public class GenTypeConst {
|
||||||
|
|
||||||
|
private GenTypeConst() {
|
||||||
|
}
|
||||||
|
|
||||||
public static final String ENTITY = "entity";
|
public static final String ENTITY = "entity";
|
||||||
public static final String MAPPER = "mapper";
|
public static final String MAPPER = "mapper";
|
||||||
public static final String SERVICE = "service";
|
public static final String SERVICE = "service";
|
||||||
@ -32,8 +35,4 @@ public class GenTypeConst {
|
|||||||
public static final String MAPPER_XML = "mapperXml";
|
public static final String MAPPER_XML = "mapperXml";
|
||||||
public static final String PACKAGE_INFO = "package-info";
|
public static final String PACKAGE_INFO = "package-info";
|
||||||
|
|
||||||
|
|
||||||
private GenTypeConst() {
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -24,6 +24,9 @@ package com.mybatisflex.codegen.constant;
|
|||||||
*/
|
*/
|
||||||
public final class TemplateConst {
|
public final class TemplateConst {
|
||||||
|
|
||||||
|
private TemplateConst() {
|
||||||
|
}
|
||||||
|
|
||||||
public static final String ENTITY = "/templates/enjoy/entity.tpl";
|
public static final String ENTITY = "/templates/enjoy/entity.tpl";
|
||||||
public static final String MAPPER = "/templates/enjoy/mapper.tpl";
|
public static final String MAPPER = "/templates/enjoy/mapper.tpl";
|
||||||
public static final String SERVICE = "/templates/enjoy/service.tpl";
|
public static final String SERVICE = "/templates/enjoy/service.tpl";
|
||||||
@ -33,7 +36,4 @@ public final class TemplateConst {
|
|||||||
public static final String MAPPER_XML = "/templates/enjoy/mapperXml.tpl";
|
public static final String MAPPER_XML = "/templates/enjoy/mapperXml.tpl";
|
||||||
public static final String PACKAGE_INFO = "/templates/enjoy/package-info.tpl";
|
public static final String PACKAGE_INFO = "/templates/enjoy/package-info.tpl";
|
||||||
|
|
||||||
private TemplateConst() {
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -0,0 +1,20 @@
|
|||||||
|
/*
|
||||||
|
* 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.constant;
|
||||||
@ -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.dialect;
|
package com.mybatisflex.codegen.dialect;
|
||||||
|
|
||||||
@ -24,8 +24,14 @@ import java.sql.DatabaseMetaData;
|
|||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 方言接口。
|
||||||
|
*/
|
||||||
public interface IDialect {
|
public interface IDialect {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 默认方言。
|
||||||
|
*/
|
||||||
IDialect DEFAULT = new JdbcDialect() {
|
IDialect DEFAULT = new JdbcDialect() {
|
||||||
@Override
|
@Override
|
||||||
String forBuildColumnsSql(String schema, String tableName) {
|
String forBuildColumnsSql(String schema, String tableName) {
|
||||||
@ -33,7 +39,9 @@ public interface IDialect {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* MySQL 方言。
|
||||||
|
*/
|
||||||
IDialect MYSQL = new JdbcDialect() {
|
IDialect MYSQL = new JdbcDialect() {
|
||||||
@Override
|
@Override
|
||||||
String forBuildColumnsSql(String schema, String tableName) {
|
String forBuildColumnsSql(String schema, String tableName) {
|
||||||
@ -41,7 +49,9 @@ public interface IDialect {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Oracle 方言。
|
||||||
|
*/
|
||||||
IDialect ORACLE = new JdbcDialect() {
|
IDialect ORACLE = new JdbcDialect() {
|
||||||
@Override
|
@Override
|
||||||
public String forBuildColumnsSql(String schema, String tableName) {
|
public String forBuildColumnsSql(String schema, String tableName) {
|
||||||
@ -54,10 +64,32 @@ public interface IDialect {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sqlite 方言。
|
||||||
|
*/
|
||||||
IDialect SQLITE = new SqliteDialect();
|
IDialect SQLITE = new SqliteDialect();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 构建表和列的信息。
|
||||||
|
*
|
||||||
|
* @param table 存入的表对象
|
||||||
|
* @param globalConfig 全局配置
|
||||||
|
* @param dbMeta 数据库元数据
|
||||||
|
* @param conn 连接
|
||||||
|
* @throws SQLException 发生 SQL 异常时抛出
|
||||||
|
*/
|
||||||
void buildTableColumns(Table table, GlobalConfig globalConfig, DatabaseMetaData dbMeta, Connection conn) throws SQLException;
|
void buildTableColumns(Table table, GlobalConfig globalConfig, DatabaseMetaData dbMeta, Connection conn) throws SQLException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取表的描述信息。
|
||||||
|
*
|
||||||
|
* @param dbMeta 数据库元数据
|
||||||
|
* @param conn 连接
|
||||||
|
* @param schema 模式
|
||||||
|
* @param types 结果集类型
|
||||||
|
* @return 结果集
|
||||||
|
* @throws SQLException 发生 SQL 异常时抛出
|
||||||
|
*/
|
||||||
ResultSet getTablesResultSet(DatabaseMetaData dbMeta, Connection conn, String schema, String[] types) throws SQLException;
|
ResultSet getTablesResultSet(DatabaseMetaData dbMeta, Connection conn, String schema, String[] types) throws SQLException;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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.dialect;
|
package com.mybatisflex.codegen.dialect;
|
||||||
|
|
||||||
@ -23,6 +23,9 @@ import java.sql.*;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 默认方言抽象类。
|
||||||
|
*/
|
||||||
public abstract class JdbcDialect implements IDialect {
|
public abstract class JdbcDialect implements IDialect {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -52,7 +55,6 @@ public abstract class JdbcDialect implements IDialect {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private Map<String, String> buildColumnRemarks(Table table, DatabaseMetaData dbMeta, Connection conn) {
|
private Map<String, String> buildColumnRemarks(Table table, DatabaseMetaData dbMeta, Connection conn) {
|
||||||
Map<String, String> columnRemarks = new HashMap<>();
|
Map<String, String> columnRemarks = new HashMap<>();
|
||||||
try (ResultSet colRs = dbMeta.getColumns(conn.getCatalog(), null, table.getName(), null)) {
|
try (ResultSet colRs = dbMeta.getColumns(conn.getCatalog(), null, table.getName(), null)) {
|
||||||
@ -65,12 +67,18 @@ public abstract class JdbcDialect implements IDialect {
|
|||||||
return columnRemarks;
|
return columnRemarks;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResultSet getTablesResultSet(DatabaseMetaData dbMeta, Connection conn, String schema, String[] types) throws SQLException {
|
public ResultSet getTablesResultSet(DatabaseMetaData dbMeta, Connection conn, String schema, String[] types) throws SQLException {
|
||||||
return dbMeta.getTables(conn.getCatalog(), schema, null, types);
|
return dbMeta.getTables(conn.getCatalog(), schema, null, types);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 构建查询所有数据的 SQL 语句。
|
||||||
|
*
|
||||||
|
* @param schema 模式
|
||||||
|
* @param tableName 表名
|
||||||
|
* @return 全量查询 SQL 语句
|
||||||
|
*/
|
||||||
abstract String forBuildColumnsSql(String schema, String tableName);
|
abstract String forBuildColumnsSql(String schema, String tableName);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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.dialect;
|
package com.mybatisflex.codegen.dialect;
|
||||||
|
|
||||||
@ -20,8 +20,14 @@ import com.mybatisflex.core.util.StringUtil;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 字段类型映射。
|
||||||
|
*/
|
||||||
public class JdbcTypeMapping {
|
public class JdbcTypeMapping {
|
||||||
|
|
||||||
|
private JdbcTypeMapping() {
|
||||||
|
}
|
||||||
|
|
||||||
private static final Map<String, String> mapping = new HashMap<>();
|
private static final Map<String, String> mapping = new HashMap<>();
|
||||||
|
|
||||||
static {
|
static {
|
||||||
@ -50,9 +56,9 @@ public class JdbcTypeMapping {
|
|||||||
registerMapping("java.time.LocalDate", "java.util.Date");
|
registerMapping("java.time.LocalDate", "java.util.Date");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static String getType(String jdbcType) {
|
static String getType(String jdbcType) {
|
||||||
String registered = mapping.get(jdbcType);
|
String registered = mapping.get(jdbcType);
|
||||||
return StringUtil.isNotBlank(registered) ? registered : jdbcType;
|
return StringUtil.isNotBlank(registered) ? registered : jdbcType;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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.dialect;
|
package com.mybatisflex.codegen.dialect;
|
||||||
|
|
||||||
@ -23,6 +23,9 @@ import java.math.BigDecimal;
|
|||||||
import java.math.BigInteger;
|
import java.math.BigInteger;
|
||||||
import java.sql.*;
|
import java.sql.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sqlite 方言实现。
|
||||||
|
*/
|
||||||
public class SqliteDialect implements IDialect {
|
public class SqliteDialect implements IDialect {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -48,13 +51,11 @@ public class SqliteDialect implements IDialect {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResultSet getTablesResultSet(DatabaseMetaData dbMeta, Connection conn, String schema, String[] types) throws SQLException {
|
public ResultSet getTablesResultSet(DatabaseMetaData dbMeta, Connection conn, String schema, String[] types) throws SQLException {
|
||||||
return dbMeta.getTables(conn.getCatalog(), schema, null, types);
|
return dbMeta.getTables(conn.getCatalog(), schema, null, types);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private String type2ClassName(String type) {
|
private String type2ClassName(String type) {
|
||||||
int indexOf = type.indexOf("(");
|
int indexOf = type.indexOf("(");
|
||||||
if (indexOf > 0) {
|
if (indexOf > 0) {
|
||||||
@ -94,4 +95,5 @@ public class SqliteDialect implements IDialect {
|
|||||||
return String.class.getName();
|
return String.class.getName();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,20 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* SQL 方言。
|
||||||
|
*/
|
||||||
|
package com.mybatisflex.codegen.dialect;
|
||||||
@ -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.entity;
|
package com.mybatisflex.codegen.entity;
|
||||||
|
|
||||||
@ -24,22 +24,51 @@ import com.mybatisflex.core.util.StringUtil;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 数据库表里面的列信息。
|
||||||
|
*/
|
||||||
public class Column {
|
public class Column {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 字段名称。
|
||||||
|
*/
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 属性名称。
|
||||||
|
*/
|
||||||
private String property;
|
private String property;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 属性类型。
|
||||||
|
*/
|
||||||
private String propertyType;
|
private String propertyType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 字段注释。
|
||||||
|
*/
|
||||||
private String comment;
|
private String comment;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否为主键。
|
||||||
|
*/
|
||||||
private boolean isPrimaryKey = false;
|
private boolean isPrimaryKey = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否自增。
|
||||||
|
*/
|
||||||
private Boolean isAutoIncrement;
|
private Boolean isAutoIncrement;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否需要生成 @Column 注解。
|
||||||
|
*/
|
||||||
private boolean needGenColumnAnnotation = false;
|
private boolean needGenColumnAnnotation = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 字段配置。
|
||||||
|
*/
|
||||||
private ColumnConfig columnConfig;
|
private ColumnConfig columnConfig;
|
||||||
|
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
@ -106,7 +135,6 @@ public class Column {
|
|||||||
return "set" + StringUtil.firstCharToUpperCase(property);
|
return "set" + StringUtil.firstCharToUpperCase(property);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public String buildComment() {
|
public String buildComment() {
|
||||||
if (StringUtil.isBlank(comment)) {
|
if (StringUtil.isBlank(comment)) {
|
||||||
return "";
|
return "";
|
||||||
@ -118,7 +146,6 @@ public class Column {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public String buildPropertyName() {
|
public String buildPropertyName() {
|
||||||
String entityJavaFileName = name;
|
String entityJavaFileName = name;
|
||||||
return StringUtil.firstCharToLowerCase(StringUtil.underlineToCamel(entityJavaFileName));
|
return StringUtil.firstCharToLowerCase(StringUtil.underlineToCamel(entityJavaFileName));
|
||||||
@ -285,7 +312,6 @@ public class Column {
|
|||||||
return importClasses;
|
return importClasses;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "Column{" +
|
return "Column{" +
|
||||||
@ -295,4 +321,5 @@ public class Column {
|
|||||||
", isAutoIncrement=" + isAutoIncrement +
|
", isAutoIncrement=" + isAutoIncrement +
|
||||||
'}';
|
'}';
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -22,17 +22,46 @@ import java.math.BigInteger;
|
|||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 数据库表信息。
|
||||||
|
*/
|
||||||
public class Table {
|
public class Table {
|
||||||
|
|
||||||
private String schema;
|
/**
|
||||||
|
* 表名。
|
||||||
|
*/
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* schema(模式)。
|
||||||
|
*/
|
||||||
|
private String schema;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 表注释。
|
||||||
|
*/
|
||||||
private String comment;
|
private String comment;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 主键。
|
||||||
|
*/
|
||||||
private Set<String> primaryKeys;
|
private Set<String> primaryKeys;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 所包含的列。
|
||||||
|
*/
|
||||||
private List<Column> columns = new ArrayList<>();
|
private List<Column> columns = new ArrayList<>();
|
||||||
|
|
||||||
private GlobalConfig globalConfig;
|
/**
|
||||||
|
* 表配置。
|
||||||
|
*/
|
||||||
private TableConfig tableConfig;
|
private TableConfig tableConfig;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 全局配置。
|
||||||
|
*/
|
||||||
|
private GlobalConfig globalConfig;
|
||||||
|
|
||||||
public String getSchema() {
|
public String getSchema() {
|
||||||
return schema;
|
return schema;
|
||||||
}
|
}
|
||||||
@ -69,7 +98,6 @@ public class Table {
|
|||||||
.orElse(null);
|
.orElse(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public Set<String> getPrimaryKeys() {
|
public Set<String> getPrimaryKeys() {
|
||||||
return primaryKeys;
|
return primaryKeys;
|
||||||
}
|
}
|
||||||
@ -98,10 +126,8 @@ public class Table {
|
|||||||
//主键
|
//主键
|
||||||
if (primaryKeys != null && primaryKeys.contains(column.getName())) {
|
if (primaryKeys != null && primaryKeys.contains(column.getName())) {
|
||||||
column.setPrimaryKey(true);
|
column.setPrimaryKey(true);
|
||||||
if (column.getAutoIncrement() == null) {
|
if (column.getAutoIncrement() == null && (column.getPropertyType().equals(Integer.class.getName()) || column.getPropertyType().equals(BigInteger.class.getName()))) {
|
||||||
if (column.getPropertyType().equals(Integer.class.getName()) || column.getPropertyType().equals(BigInteger.class.getName())) {
|
column.setAutoIncrement(true);
|
||||||
column.setAutoIncrement(true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -130,9 +156,13 @@ public class Table {
|
|||||||
this.tableConfig = tableConfig;
|
this.tableConfig = tableConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ===== 构建实体类文件 =====
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 构建 import 导包。
|
||||||
|
*/
|
||||||
public List<String> buildImports() {
|
public List<String> buildImports() {
|
||||||
Set<String> imports = new HashSet<>();
|
Set<String> imports = new HashSet<>();
|
||||||
// imports.add(com.mybatisflex.annotation.Table.class.getName());
|
|
||||||
imports.add("com.mybatisflex.annotation.Table");
|
imports.add("com.mybatisflex.annotation.Table");
|
||||||
for (Column column : columns) {
|
for (Column column : columns) {
|
||||||
imports.addAll(column.getImportClasses());
|
imports.addAll(column.getImportClasses());
|
||||||
@ -165,115 +195,8 @@ public class Table {
|
|||||||
return imports.stream().sorted(Comparator.naturalOrder()).collect(Collectors.toList());
|
return imports.stream().sorted(Comparator.naturalOrder()).collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getEntityJavaFileName() {
|
|
||||||
String entityJavaFileName = name;
|
|
||||||
String tablePrefix = globalConfig.getStrategyConfig().getTablePrefix();
|
|
||||||
if (tablePrefix != null) {
|
|
||||||
String[] tablePrefixes = tablePrefix.split(",");
|
|
||||||
for (String prefix : tablePrefixes) {
|
|
||||||
String trimPrefix = prefix.trim();
|
|
||||||
if (trimPrefix.length() > 0 && name.startsWith(trimPrefix)) {
|
|
||||||
entityJavaFileName = name.substring(trimPrefix.length());
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return StringUtil.firstCharToUpperCase(StringUtil.underlineToCamel(entityJavaFileName));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 构建 entity 的 Class 名称
|
* 构建 @Table(...) 注解。
|
||||||
*
|
|
||||||
* @return className
|
|
||||||
*/
|
|
||||||
public String buildEntityClassName() {
|
|
||||||
String entityJavaFileName = getEntityJavaFileName();
|
|
||||||
EntityConfig entityConfig = globalConfig.getEntityConfig();
|
|
||||||
return entityConfig.getClassPrefix()
|
|
||||||
+ entityJavaFileName
|
|
||||||
+ entityConfig.getClassSuffix();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 构建 tableDef 的 Class 名称
|
|
||||||
*
|
|
||||||
* @return className
|
|
||||||
*/
|
|
||||||
public String buildTableDefClassName() {
|
|
||||||
String tableDefJavaFileName = getEntityJavaFileName();
|
|
||||||
TableDefConfig tableDefConfig = globalConfig.getTableDefConfig();
|
|
||||||
return tableDefConfig.getClassPrefix()
|
|
||||||
+ tableDefJavaFileName
|
|
||||||
+ tableDefConfig.getClassSuffix();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 构建 MapperXml 的文件名称
|
|
||||||
*
|
|
||||||
* @return fileName
|
|
||||||
*/
|
|
||||||
public String buildMapperXmlFileName() {
|
|
||||||
String tableDefJavaFileName = getEntityJavaFileName();
|
|
||||||
MapperXmlConfig mapperXmlConfig = globalConfig.getMapperXmlConfig();
|
|
||||||
return mapperXmlConfig.getFilePrefix()
|
|
||||||
+ tableDefJavaFileName
|
|
||||||
+ mapperXmlConfig.getFileSuffix();
|
|
||||||
}
|
|
||||||
|
|
||||||
public String buildExtends() {
|
|
||||||
EntityConfig entityConfig = globalConfig.getEntityConfig();
|
|
||||||
if (entityConfig.getSupperClass() != null) {
|
|
||||||
return " extends " + entityConfig.getSupperClass().getSimpleName();
|
|
||||||
} else {
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public String buildImplements() {
|
|
||||||
Class<?>[] entityInterfaces = globalConfig.getEntityConfig().getImplInterfaces();
|
|
||||||
if (entityInterfaces != null && entityInterfaces.length > 0) {
|
|
||||||
return " implements " + StringUtil.join(", ", Arrays.stream(entityInterfaces)
|
|
||||||
.map(Class::getSimpleName).collect(Collectors.toList()));
|
|
||||||
} else {
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public String buildMapperClassName() {
|
|
||||||
String entityJavaFileName = getEntityJavaFileName();
|
|
||||||
MapperConfig mapperConfig = globalConfig.getMapperConfig();
|
|
||||||
return mapperConfig.getClassPrefix()
|
|
||||||
+ entityJavaFileName
|
|
||||||
+ mapperConfig.getClassSuffix();
|
|
||||||
}
|
|
||||||
|
|
||||||
public String buildServiceClassName() {
|
|
||||||
String entityJavaFileName = getEntityJavaFileName();
|
|
||||||
ServiceConfig serviceConfig = globalConfig.getServiceConfig();
|
|
||||||
return serviceConfig.getClassPrefix()
|
|
||||||
+ entityJavaFileName
|
|
||||||
+ serviceConfig.getClassSuffix();
|
|
||||||
}
|
|
||||||
|
|
||||||
public String buildServiceImplClassName() {
|
|
||||||
String entityJavaFileName = getEntityJavaFileName();
|
|
||||||
ServiceImplConfig serviceImplConfig = globalConfig.getServiceImplConfig();
|
|
||||||
return serviceImplConfig.getClassPrefix()
|
|
||||||
+ entityJavaFileName
|
|
||||||
+ serviceImplConfig.getClassSuffix();
|
|
||||||
}
|
|
||||||
|
|
||||||
public String buildControllerClassName() {
|
|
||||||
String entityJavaFileName = getEntityJavaFileName();
|
|
||||||
ControllerConfig controllerConfig = globalConfig.getControllerConfig();
|
|
||||||
return controllerConfig.getClassPrefix()
|
|
||||||
+ entityJavaFileName
|
|
||||||
+ controllerConfig.getClassSuffix();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 构建 @Table(...) 注解
|
|
||||||
*/
|
*/
|
||||||
public String buildTableAnnotation() {
|
public String buildTableAnnotation() {
|
||||||
StringBuilder tableAnnotation = new StringBuilder();
|
StringBuilder tableAnnotation = new StringBuilder();
|
||||||
@ -307,6 +230,129 @@ public class Table {
|
|||||||
return tableAnnotation.append(")").toString();
|
return tableAnnotation.append(")").toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 构建 extends 继承。
|
||||||
|
*/
|
||||||
|
public String buildExtends() {
|
||||||
|
EntityConfig entityConfig = globalConfig.getEntityConfig();
|
||||||
|
if (entityConfig.getSupperClass() != null) {
|
||||||
|
return " extends " + entityConfig.getSupperClass().getSimpleName();
|
||||||
|
} else {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 构建 implements 实现。
|
||||||
|
*/
|
||||||
|
public String buildImplements() {
|
||||||
|
Class<?>[] entityInterfaces = globalConfig.getEntityConfig().getImplInterfaces();
|
||||||
|
if (entityInterfaces != null && entityInterfaces.length > 0) {
|
||||||
|
return " implements " + StringUtil.join(", ", Arrays.stream(entityInterfaces)
|
||||||
|
.map(Class::getSimpleName).collect(Collectors.toList()));
|
||||||
|
} else {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ===== 构建相关类名 =====
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取生成 Java 文件名。
|
||||||
|
*/
|
||||||
|
public String getEntityJavaFileName() {
|
||||||
|
String entityJavaFileName = name;
|
||||||
|
String tablePrefix = globalConfig.getStrategyConfig().getTablePrefix();
|
||||||
|
if (tablePrefix != null) {
|
||||||
|
String[] tablePrefixes = tablePrefix.split(",");
|
||||||
|
for (String prefix : tablePrefixes) {
|
||||||
|
String trimPrefix = prefix.trim();
|
||||||
|
if (trimPrefix.length() > 0 && name.startsWith(trimPrefix)) {
|
||||||
|
entityJavaFileName = name.substring(trimPrefix.length());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return StringUtil.firstCharToUpperCase(StringUtil.underlineToCamel(entityJavaFileName));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 构建 entity 的 Class 名称。
|
||||||
|
*/
|
||||||
|
public String buildEntityClassName() {
|
||||||
|
String entityJavaFileName = getEntityJavaFileName();
|
||||||
|
EntityConfig entityConfig = globalConfig.getEntityConfig();
|
||||||
|
return entityConfig.getClassPrefix()
|
||||||
|
+ entityJavaFileName
|
||||||
|
+ entityConfig.getClassSuffix();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 构建 tableDef 的 Class 名称。
|
||||||
|
*/
|
||||||
|
public String buildTableDefClassName() {
|
||||||
|
String tableDefJavaFileName = getEntityJavaFileName();
|
||||||
|
TableDefConfig tableDefConfig = globalConfig.getTableDefConfig();
|
||||||
|
return tableDefConfig.getClassPrefix()
|
||||||
|
+ tableDefJavaFileName
|
||||||
|
+ tableDefConfig.getClassSuffix();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 构建 mapper 的 Class 名称。
|
||||||
|
*/
|
||||||
|
public String buildMapperClassName() {
|
||||||
|
String entityJavaFileName = getEntityJavaFileName();
|
||||||
|
MapperConfig mapperConfig = globalConfig.getMapperConfig();
|
||||||
|
return mapperConfig.getClassPrefix()
|
||||||
|
+ entityJavaFileName
|
||||||
|
+ mapperConfig.getClassSuffix();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 构建 service 的 Class 名称。
|
||||||
|
*/
|
||||||
|
public String buildServiceClassName() {
|
||||||
|
String entityJavaFileName = getEntityJavaFileName();
|
||||||
|
ServiceConfig serviceConfig = globalConfig.getServiceConfig();
|
||||||
|
return serviceConfig.getClassPrefix()
|
||||||
|
+ entityJavaFileName
|
||||||
|
+ serviceConfig.getClassSuffix();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 构建 serviceImpl 的 Class 名称。
|
||||||
|
*/
|
||||||
|
public String buildServiceImplClassName() {
|
||||||
|
String entityJavaFileName = getEntityJavaFileName();
|
||||||
|
ServiceImplConfig serviceImplConfig = globalConfig.getServiceImplConfig();
|
||||||
|
return serviceImplConfig.getClassPrefix()
|
||||||
|
+ entityJavaFileName
|
||||||
|
+ serviceImplConfig.getClassSuffix();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 构建 controller 的 Class 名称。
|
||||||
|
*/
|
||||||
|
public String buildControllerClassName() {
|
||||||
|
String entityJavaFileName = getEntityJavaFileName();
|
||||||
|
ControllerConfig controllerConfig = globalConfig.getControllerConfig();
|
||||||
|
return controllerConfig.getClassPrefix()
|
||||||
|
+ entityJavaFileName
|
||||||
|
+ controllerConfig.getClassSuffix();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 构建 MapperXml 的文件名称。
|
||||||
|
*/
|
||||||
|
public String buildMapperXmlFileName() {
|
||||||
|
String tableDefJavaFileName = getEntityJavaFileName();
|
||||||
|
MapperXmlConfig mapperXmlConfig = globalConfig.getMapperXmlConfig();
|
||||||
|
return mapperXmlConfig.getFilePrefix()
|
||||||
|
+ tableDefJavaFileName
|
||||||
|
+ mapperXmlConfig.getFileSuffix();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "Table{" +
|
return "Table{" +
|
||||||
@ -318,5 +364,4 @@ public class Table {
|
|||||||
'}';
|
'}';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,20 @@
|
|||||||
|
/*
|
||||||
|
* 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.entity;
|
||||||
@ -22,6 +22,11 @@ import java.util.Collection;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 代码生成器工厂,用于创建各种类型文件的生成。
|
||||||
|
*
|
||||||
|
* @see GenTypeConst
|
||||||
|
*/
|
||||||
public class GeneratorFactory {
|
public class GeneratorFactory {
|
||||||
|
|
||||||
private static final Map<String, IGenerator> generators = new HashMap<>();
|
private static final Map<String, IGenerator> generators = new HashMap<>();
|
||||||
@ -37,17 +42,36 @@ public class GeneratorFactory {
|
|||||||
registerGenerator(GenTypeConst.PACKAGE_INFO, new PackageInfoGenerator());
|
registerGenerator(GenTypeConst.PACKAGE_INFO, new PackageInfoGenerator());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private GeneratorFactory() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取指定类型文件的生成器。
|
||||||
|
*
|
||||||
|
* @param genType 生成类型
|
||||||
|
* @return 该类型的文件生成器
|
||||||
|
*/
|
||||||
public static IGenerator getGenerator(String genType) {
|
public static IGenerator getGenerator(String genType) {
|
||||||
return generators.get(genType);
|
return generators.get(genType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取所有的文件生成器。
|
||||||
|
*
|
||||||
|
* @return 所有的文件生成器
|
||||||
|
*/
|
||||||
public static Collection<IGenerator> getGenerators() {
|
public static Collection<IGenerator> getGenerators() {
|
||||||
return generators.values();
|
return generators.values();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 注册文件生成器。
|
||||||
|
*
|
||||||
|
* @param name 生成器名称
|
||||||
|
* @param generator 生成器
|
||||||
|
*/
|
||||||
public static void registerGenerator(String name, IGenerator generator) {
|
public static void registerGenerator(String name, IGenerator generator) {
|
||||||
generators.put(name, generator);
|
generators.put(name, generator);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -98,6 +98,9 @@ public class PackageInfoGenerator implements IGenerator {
|
|||||||
this.templatePath = templatePath;
|
this.templatePath = templatePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 内置类,用于存放数据。
|
||||||
|
*/
|
||||||
private static class Data {
|
private static class Data {
|
||||||
|
|
||||||
String packageName;
|
String packageName;
|
||||||
|
|||||||
@ -0,0 +1,20 @@
|
|||||||
|
/*
|
||||||
|
* 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.generator.impl;
|
||||||
@ -0,0 +1,20 @@
|
|||||||
|
/*
|
||||||
|
* 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.generator;
|
||||||
@ -1,25 +1,36 @@
|
|||||||
/**
|
/*
|
||||||
* 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.template;
|
package com.mybatisflex.codegen.template;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 模板引擎。
|
||||||
|
*/
|
||||||
|
@FunctionalInterface
|
||||||
public interface ITemplate {
|
public interface ITemplate {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 使用模板引擎生成代码。
|
||||||
|
*
|
||||||
|
* @param params 生成参数
|
||||||
|
* @param templateFilePath 模板文件位置
|
||||||
|
* @param generateFile 生成文件位置
|
||||||
|
*/
|
||||||
void generate(Map<String, Object> params, String templateFilePath, File generateFile);
|
void generate(Map<String, Object> params, String templateFilePath, File generateFile);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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.template.impl;
|
package com.mybatisflex.codegen.template.impl;
|
||||||
|
|
||||||
@ -28,6 +28,9 @@ import java.io.File;
|
|||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <a href=https://jfinal.com/doc/6-1>JFinal Enjoy</a> 模板引擎实现。
|
||||||
|
*/
|
||||||
public class EnjoyTemplate implements ITemplate {
|
public class EnjoyTemplate implements ITemplate {
|
||||||
|
|
||||||
private final Engine engine;
|
private final Engine engine;
|
||||||
@ -43,17 +46,22 @@ public class EnjoyTemplate implements ITemplate {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void generate(Map<String, Object> params, String templateFilePath, File generateFile) {
|
public void generate(Map<String, Object> params, String templateFilePath, File generateFile) {
|
||||||
if (!generateFile.getParentFile().exists() && !generateFile.getParentFile().mkdirs()){
|
if (!generateFile.getParentFile().exists() && !generateFile.getParentFile().mkdirs()) {
|
||||||
throw new IllegalStateException("Can not mkdirs by dir: " + generateFile.getParentFile());
|
throw new IllegalStateException("Can not mkdirs by dir: " + generateFile.getParentFile());
|
||||||
}
|
}
|
||||||
|
// 开始生成文件
|
||||||
try(FileOutputStream fileOutputStream = new FileOutputStream(generateFile)) {
|
try (FileOutputStream fileOutputStream = new FileOutputStream(generateFile)) {
|
||||||
engine.getTemplate(templateFilePath).render(params, fileOutputStream);
|
engine.getTemplate(templateFilePath).render(params, fileOutputStream);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 从文件或者类路径读取模板。
|
||||||
|
*
|
||||||
|
* @author 王帅
|
||||||
|
*/
|
||||||
public static class FileAndClassPathSourceFactory implements ISourceFactory {
|
public static class FileAndClassPathSourceFactory implements ISourceFactory {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@ -0,0 +1,20 @@
|
|||||||
|
/*
|
||||||
|
* 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.template.impl;
|
||||||
@ -0,0 +1,20 @@
|
|||||||
|
/*
|
||||||
|
* 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.template;
|
||||||
Loading…
x
Reference in New Issue
Block a user