代码生成模块
This commit is contained in:
parent
486dd07e43
commit
6f3f81480f
@ -67,6 +67,11 @@
|
|||||||
<groupId>org.apache.commons</groupId>
|
<groupId>org.apache.commons</groupId>
|
||||||
<artifactId>commons-compress</artifactId>
|
<artifactId>commons-compress</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<!--HikariCP-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.zaxxer</groupId>
|
||||||
|
<artifactId>HikariCP</artifactId>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
|||||||
29
Cpop-Generator/pom.xml
Normal file
29
Cpop-Generator/pom.xml
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<parent>
|
||||||
|
<groupId>com.cpop</groupId>
|
||||||
|
<artifactId>Cpop-Union</artifactId>
|
||||||
|
<version>1.0.0</version>
|
||||||
|
<relativePath>../pom.xml</relativePath> <!-- lookup parent from repository -->
|
||||||
|
</parent>
|
||||||
|
<artifactId>Cpop-Generator</artifactId>
|
||||||
|
<name>Cpop-Generator</name>
|
||||||
|
<description>代码生成模块</description>
|
||||||
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<!--代码生成器-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.mybatis-flex</groupId>
|
||||||
|
<artifactId>mybatis-flex-codegen</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<!--核心包-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.cpop</groupId>
|
||||||
|
<artifactId>Cpop-Core</artifactId>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
</project>
|
||||||
@ -0,0 +1,158 @@
|
|||||||
|
package com.cpop.generator;
|
||||||
|
|
||||||
|
import com.cpop.common.utils.DateUtils;
|
||||||
|
import com.cpop.common.utils.StringUtils;
|
||||||
|
import com.cpop.core.base.entity.BaseEntity;
|
||||||
|
import com.cpop.core.base.entity.BaseInsertListener;
|
||||||
|
import com.cpop.core.base.entity.BaseUpdateListener;
|
||||||
|
import com.mybatisflex.codegen.Generator;
|
||||||
|
import com.mybatisflex.codegen.config.EntityConfig;
|
||||||
|
import com.mybatisflex.codegen.config.GlobalConfig;
|
||||||
|
import com.mybatisflex.codegen.config.TableConfig;
|
||||||
|
import com.mybatisflex.core.exception.MybatisFlexException;
|
||||||
|
import com.zaxxer.hikari.HikariDataSource;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Scanner;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author: DB
|
||||||
|
* @Date: 2023/08/04/13:48
|
||||||
|
* @Description: 代码生成
|
||||||
|
*/
|
||||||
|
public class CpopGenerator {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 数据库 URL
|
||||||
|
*/
|
||||||
|
private static final String URL = "jdbc:mysql://localhost:3306/cpop-union?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 数据库用户名
|
||||||
|
*/
|
||||||
|
private static final String USERNAME = "root";
|
||||||
|
/**
|
||||||
|
* 数据库密码
|
||||||
|
*/
|
||||||
|
private static final String PASSWORD = "root";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 输出路径
|
||||||
|
*/
|
||||||
|
private static final String EXPORT_URL = "/Cpop-Jambox";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 模块
|
||||||
|
*/
|
||||||
|
private static final String EXPORT_ITEM = "jambox";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 表前缀
|
||||||
|
*/
|
||||||
|
private static final String TABLE_PREFIX = "cp_j_";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 主入口
|
||||||
|
* @param args
|
||||||
|
*/
|
||||||
|
public static void main(String[] args) {
|
||||||
|
//配置数据源
|
||||||
|
try (HikariDataSource dataSource = new HikariDataSource()) {
|
||||||
|
dataSource.setJdbcUrl(URL);
|
||||||
|
dataSource.setUsername(USERNAME);
|
||||||
|
dataSource.setPassword(PASSWORD);
|
||||||
|
//创建配置内容,两种风格都可以。
|
||||||
|
GlobalConfig globalConfig = createGlobalConfig();
|
||||||
|
//GlobalConfig globalConfig = createGlobalConfigUseStyle2();
|
||||||
|
//通过 datasource 和 globalConfig 创建代码生成器
|
||||||
|
Generator generator = new Generator(dataSource, globalConfig);
|
||||||
|
/*GeneratorFactory.registerGenerator("bo", new BoGenerator());
|
||||||
|
GeneratorFactory.registerGenerator("vo", new VoGenerator());
|
||||||
|
GeneratorFactory.registerGenerator("pageBo", new PageBoGenerator());
|
||||||
|
GeneratorFactory.registerGenerator("pageVo", new PageVoGenerator());
|
||||||
|
GeneratorFactory.registerGenerator("dto", new DtoGenerator());*/
|
||||||
|
//生成代码
|
||||||
|
generator.generate();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 命令行输入表名
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private static String scanner() {
|
||||||
|
Scanner scanner = new Scanner(System.in);
|
||||||
|
System.out.println("请输入表名,多个英文逗号分割:");
|
||||||
|
if (scanner.hasNext()) {
|
||||||
|
String ipt = scanner.next();
|
||||||
|
if (StringUtils.isNotBlank(ipt)) {
|
||||||
|
return ipt;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
throw new MybatisFlexException("请输入正确的表名,多个英文逗号分割!");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description: 构建代码生成配置
|
||||||
|
* @param
|
||||||
|
* @return GlobalConfig
|
||||||
|
* @author DB
|
||||||
|
* @Date: 2023/8/4 0004 14:05
|
||||||
|
*/
|
||||||
|
private static GlobalConfig createGlobalConfig(){
|
||||||
|
String[] tables = scanner().split(",");
|
||||||
|
//创建配置内容
|
||||||
|
GlobalConfig globalConfig = new GlobalConfig();
|
||||||
|
|
||||||
|
//设置注释配置
|
||||||
|
globalConfig.getJavadocConfig()
|
||||||
|
.setAuthor("DB")
|
||||||
|
.setSince(DateUtils.getDate());
|
||||||
|
//设置包配置
|
||||||
|
globalConfig.getPackageConfig()
|
||||||
|
.setSourceDir(System.getProperty("user.dir") + EXPORT_URL + "/src/main/java")
|
||||||
|
.setBasePackage("com.cpop." + EXPORT_ITEM + ".business")
|
||||||
|
.setMapperXmlPath(System.getProperty("user.dir") + EXPORT_URL + "/src/main/resources/mapper");
|
||||||
|
//设置策略配置
|
||||||
|
globalConfig.getStrategyConfig()
|
||||||
|
.setTablePrefix(TABLE_PREFIX)
|
||||||
|
.setLogicDeleteColumn("is_delete")
|
||||||
|
.setGenerateTable(tables);
|
||||||
|
//设置模板配置
|
||||||
|
globalConfig.getTemplateConfig()
|
||||||
|
.setEntity(System.getProperty("user.dir") + "/Cpop-Generator/src/main/resources/template/enjoy/entity.tpl")
|
||||||
|
.setMapper(System.getProperty("user.dir") + "/Cpop-Generator/src/main/resources/template/enjoy/mapper.tpl")
|
||||||
|
.setService(System.getProperty("user.dir") + "/Cpop-Generator/src/main/resources/template/enjoy/service.tpl")
|
||||||
|
.setServiceImpl(System.getProperty("user.dir") + "/Cpop-Generator/src/main/resources/template/enjoy/serviceImpl.tpl")
|
||||||
|
.setController(System.getProperty("user.dir") + "/Cpop-Generator/src/main/resources/template/enjoy/controller.tpl")
|
||||||
|
.setMapperXml(System.getProperty("user.dir") + "/Cpop-Generator/src/main/resources/template/enjoy/mapperXml.tpl");
|
||||||
|
//Entity 生成配置
|
||||||
|
globalConfig.getEntityConfig()
|
||||||
|
.setSuperClass(BaseEntity.class)
|
||||||
|
.setWithLombok(true)
|
||||||
|
.setWithSwagger(true)
|
||||||
|
.setSwaggerVersion(EntityConfig.SwaggerVersion.FOX);
|
||||||
|
// 开启 Entity 的生成
|
||||||
|
globalConfig.enableEntity();
|
||||||
|
// 开启 Mapper 的生成
|
||||||
|
globalConfig.enableMapper();
|
||||||
|
// 开启 Service 的生成
|
||||||
|
globalConfig.enableService();
|
||||||
|
// 开启 ServiceImpl 的生成
|
||||||
|
globalConfig.enableServiceImpl();
|
||||||
|
// 开启 Controller 的生成
|
||||||
|
globalConfig.enableController();
|
||||||
|
// 开启 xml 的生成
|
||||||
|
globalConfig.enableMapperXml();
|
||||||
|
//遍历设置表配置
|
||||||
|
Arrays.asList(tables).forEach(item -> {
|
||||||
|
TableConfig tableConfig = new TableConfig();
|
||||||
|
tableConfig.setInsertListenerClass(BaseInsertListener.class);
|
||||||
|
tableConfig.setUpdateListenerClass(BaseUpdateListener.class);
|
||||||
|
tableConfig.setTableName(item);
|
||||||
|
tableConfig.setMapperGenerateEnable(false);
|
||||||
|
globalConfig.setTableConfig(tableConfig);
|
||||||
|
});
|
||||||
|
return globalConfig;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,60 @@
|
|||||||
|
package com.cpop.generator.template;
|
||||||
|
|
||||||
|
import com.mybatisflex.codegen.config.EntityConfig;
|
||||||
|
import com.mybatisflex.codegen.config.GlobalConfig;
|
||||||
|
import com.mybatisflex.codegen.config.PackageConfig;
|
||||||
|
import com.mybatisflex.codegen.entity.Table;
|
||||||
|
import com.mybatisflex.codegen.generator.IGenerator;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author: DB
|
||||||
|
* @Date: 2023/08/04/17:07
|
||||||
|
* @Description:
|
||||||
|
*/
|
||||||
|
public class BoGenerator implements IGenerator {
|
||||||
|
|
||||||
|
private String templatePath = System.getProperty("user.dir") + "/Cpop-Generator/src/main/resources/template/enjoy/bo.tpl";
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getTemplatePath() {
|
||||||
|
return templatePath;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setTemplatePath(String templatePath) {
|
||||||
|
this.templatePath = templatePath;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void generate(Table table, GlobalConfig globalConfig) {
|
||||||
|
|
||||||
|
if (!globalConfig.isEntityGenerateEnable()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
PackageConfig packageConfig = globalConfig.getPackageConfig();
|
||||||
|
EntityConfig entityConfig = globalConfig.getEntityConfig();
|
||||||
|
//获取路径
|
||||||
|
String boPackagePath = packageConfig.getBasePackage().replace(".", "/") + "/bo";
|
||||||
|
File boJavaFile = new File(packageConfig.getSourceDir(), boPackagePath + "/" +
|
||||||
|
table.buildEntityClassName() + "Bo.java");
|
||||||
|
|
||||||
|
if (boJavaFile.exists() && !entityConfig.isOverwriteEnable()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, Object> params = new HashMap<>(4);
|
||||||
|
params.put("table", table);
|
||||||
|
params.put("entityConfig", entityConfig);
|
||||||
|
params.put("packageConfig", packageConfig);
|
||||||
|
params.put("javadocConfig", globalConfig.getJavadocConfig());
|
||||||
|
|
||||||
|
globalConfig.getTemplateConfig().getTemplate().generate(params, templatePath, boJavaFile);
|
||||||
|
|
||||||
|
System.out.println("Bo ---> " + boJavaFile);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,60 @@
|
|||||||
|
package com.cpop.generator.template;
|
||||||
|
|
||||||
|
import com.mybatisflex.codegen.config.EntityConfig;
|
||||||
|
import com.mybatisflex.codegen.config.GlobalConfig;
|
||||||
|
import com.mybatisflex.codegen.config.PackageConfig;
|
||||||
|
import com.mybatisflex.codegen.entity.Table;
|
||||||
|
import com.mybatisflex.codegen.generator.IGenerator;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author: DB
|
||||||
|
* @Date: 2023/08/04/17:07
|
||||||
|
* @Description:
|
||||||
|
*/
|
||||||
|
public class DtoGenerator implements IGenerator {
|
||||||
|
|
||||||
|
private String templatePath = System.getProperty("user.dir") + "/Cpop-Generator/src/main/resources/template/enjoy/dto.tpl";
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getTemplatePath() {
|
||||||
|
return templatePath;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setTemplatePath(String templatePath) {
|
||||||
|
this.templatePath = templatePath;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void generate(Table table, GlobalConfig globalConfig) {
|
||||||
|
|
||||||
|
if (!globalConfig.isEntityGenerateEnable()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
PackageConfig packageConfig = globalConfig.getPackageConfig();
|
||||||
|
EntityConfig entityConfig = globalConfig.getEntityConfig();
|
||||||
|
|
||||||
|
//获取路径
|
||||||
|
String dtoPackagePath = packageConfig.getBasePackage().replace(".", "/") + "/dto";
|
||||||
|
File dtoJavaFile = new File(packageConfig.getSourceDir(), dtoPackagePath + "/" +
|
||||||
|
table.buildEntityClassName() + "Dto.java");
|
||||||
|
|
||||||
|
if (dtoJavaFile.exists() && !entityConfig.isOverwriteEnable()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, Object> params = new HashMap<>(4);
|
||||||
|
params.put("table", table);
|
||||||
|
params.put("entityConfig", entityConfig);
|
||||||
|
params.put("packageConfig", packageConfig);
|
||||||
|
params.put("javadocConfig", globalConfig.getJavadocConfig());
|
||||||
|
|
||||||
|
globalConfig.getTemplateConfig().getTemplate().generate(params, templatePath, dtoJavaFile);
|
||||||
|
System.out.println("Dto ---> " + dtoJavaFile);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,60 @@
|
|||||||
|
package com.cpop.generator.template;
|
||||||
|
|
||||||
|
import com.mybatisflex.codegen.config.EntityConfig;
|
||||||
|
import com.mybatisflex.codegen.config.GlobalConfig;
|
||||||
|
import com.mybatisflex.codegen.config.PackageConfig;
|
||||||
|
import com.mybatisflex.codegen.entity.Table;
|
||||||
|
import com.mybatisflex.codegen.generator.IGenerator;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author: DB
|
||||||
|
* @Date: 2023/08/04/17:07
|
||||||
|
* @Description:
|
||||||
|
*/
|
||||||
|
public class PageBoGenerator implements IGenerator {
|
||||||
|
|
||||||
|
private String templatePath = System.getProperty("user.dir") + "/Cpop-Generator/src/main/resources/template/enjoy/pageBo.tpl";
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getTemplatePath() {
|
||||||
|
return templatePath;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setTemplatePath(String templatePath) {
|
||||||
|
this.templatePath = templatePath;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void generate(Table table, GlobalConfig globalConfig) {
|
||||||
|
|
||||||
|
if (!globalConfig.isEntityGenerateEnable()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
PackageConfig packageConfig = globalConfig.getPackageConfig();
|
||||||
|
EntityConfig entityConfig = globalConfig.getEntityConfig();
|
||||||
|
|
||||||
|
//获取路径
|
||||||
|
String pageBoPackagePath = packageConfig.getBasePackage().replace(".", "/") + "/bo";
|
||||||
|
File pageBoJavaFile = new File(packageConfig.getSourceDir(), pageBoPackagePath + "/" +
|
||||||
|
table.buildEntityClassName() + "PageBo.java");
|
||||||
|
|
||||||
|
if (pageBoJavaFile.exists() && !entityConfig.isOverwriteEnable()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, Object> params = new HashMap<>(4);
|
||||||
|
params.put("table", table);
|
||||||
|
params.put("entityConfig", entityConfig);
|
||||||
|
params.put("packageConfig", packageConfig);
|
||||||
|
params.put("javadocConfig", globalConfig.getJavadocConfig());
|
||||||
|
|
||||||
|
globalConfig.getTemplateConfig().getTemplate().generate(params, templatePath, pageBoJavaFile);
|
||||||
|
System.out.println("PageBo ---> " + pageBoJavaFile);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,61 @@
|
|||||||
|
package com.cpop.generator.template;
|
||||||
|
|
||||||
|
import com.mybatisflex.codegen.config.EntityConfig;
|
||||||
|
import com.mybatisflex.codegen.config.GlobalConfig;
|
||||||
|
import com.mybatisflex.codegen.config.PackageConfig;
|
||||||
|
import com.mybatisflex.codegen.entity.Table;
|
||||||
|
import com.mybatisflex.codegen.generator.IGenerator;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author: DB
|
||||||
|
* @Date: 2023/08/04/17:07
|
||||||
|
* @Description:
|
||||||
|
*/
|
||||||
|
public class PageVoGenerator implements IGenerator {
|
||||||
|
|
||||||
|
private String templatePath = System.getProperty("user.dir") + "/Cpop-Generator/src/main/resources/template/enjoy/pageVo.tpl";
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getTemplatePath() {
|
||||||
|
return templatePath;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setTemplatePath(String templatePath) {
|
||||||
|
this.templatePath = templatePath;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void generate(Table table, GlobalConfig globalConfig) {
|
||||||
|
|
||||||
|
if (!globalConfig.isEntityGenerateEnable()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
PackageConfig packageConfig = globalConfig.getPackageConfig();
|
||||||
|
EntityConfig entityConfig = globalConfig.getEntityConfig();
|
||||||
|
|
||||||
|
//获取路径
|
||||||
|
String pageVoPackagePath = packageConfig.getBasePackage().replace(".", "/") + "/vo";
|
||||||
|
File pageVoJavaFile = new File(packageConfig.getSourceDir(), pageVoPackagePath + "/" +
|
||||||
|
table.buildEntityClassName() + "PageVo.java");
|
||||||
|
|
||||||
|
if (pageVoJavaFile.exists() && !entityConfig.isOverwriteEnable()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Map<String, Object> params = new HashMap<>(4);
|
||||||
|
params.put("table", table);
|
||||||
|
params.put("entityConfig", entityConfig);
|
||||||
|
params.put("packageConfig", packageConfig);
|
||||||
|
params.put("javadocConfig", globalConfig.getJavadocConfig());
|
||||||
|
|
||||||
|
globalConfig.getTemplateConfig().getTemplate().generate(params, templatePath, pageVoJavaFile);
|
||||||
|
System.out.println("PageBo ---> " + pageVoJavaFile);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,61 @@
|
|||||||
|
package com.cpop.generator.template;
|
||||||
|
|
||||||
|
import com.mybatisflex.codegen.config.EntityConfig;
|
||||||
|
import com.mybatisflex.codegen.config.GlobalConfig;
|
||||||
|
import com.mybatisflex.codegen.config.PackageConfig;
|
||||||
|
import com.mybatisflex.codegen.entity.Table;
|
||||||
|
import com.mybatisflex.codegen.generator.IGenerator;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author: DB
|
||||||
|
* @Date: 2023/08/04/17:07
|
||||||
|
* @Description:
|
||||||
|
*/
|
||||||
|
public class VoGenerator implements IGenerator {
|
||||||
|
|
||||||
|
private String templatePath = System.getProperty("user.dir") + "/Cpop-Generator/src/main/resources/template/enjoy/vo.tpl";
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getTemplatePath() {
|
||||||
|
return templatePath;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setTemplatePath(String templatePath) {
|
||||||
|
this.templatePath = templatePath;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void generate(Table table, GlobalConfig globalConfig) {
|
||||||
|
|
||||||
|
if (!globalConfig.isEntityGenerateEnable()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
PackageConfig packageConfig = globalConfig.getPackageConfig();
|
||||||
|
EntityConfig entityConfig = globalConfig.getEntityConfig();
|
||||||
|
|
||||||
|
//获取路径
|
||||||
|
String voPackagePath = packageConfig.getBasePackage().replace(".", "/") + "/vo";
|
||||||
|
File voJavaFile = new File(packageConfig.getSourceDir(), voPackagePath + "/" +
|
||||||
|
table.buildEntityClassName() + "Vo.java");
|
||||||
|
|
||||||
|
if (voJavaFile.exists() && !entityConfig.isOverwriteEnable()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Map<String, Object> params = new HashMap<>(4);
|
||||||
|
params.put("table", table);
|
||||||
|
params.put("entityConfig", entityConfig);
|
||||||
|
params.put("packageConfig", packageConfig);
|
||||||
|
params.put("javadocConfig", globalConfig.getJavadocConfig());
|
||||||
|
|
||||||
|
globalConfig.getTemplateConfig().getTemplate().generate(params, templatePath, voJavaFile);
|
||||||
|
System.out.println("Vo ---> " + voJavaFile);
|
||||||
|
}
|
||||||
|
}
|
||||||
103
Cpop-Generator/src/main/resources/template.enjoy/bo.tpl
Normal file
103
Cpop-Generator/src/main/resources/template.enjoy/bo.tpl
Normal file
@ -0,0 +1,103 @@
|
|||||||
|
#set(withLombok = entityConfig.isWithLombok())
|
||||||
|
#set(withSwagger = entityConfig.isWithSwagger())
|
||||||
|
#set(swaggerVersion = entityConfig.getSwaggerVersion())
|
||||||
|
#set(withActiveRecord = entityConfig.isWithActiveRecord())
|
||||||
|
#set(entityClassName = table.buildEntityClassName())
|
||||||
|
package #(packageConfig.basePackage).bo;
|
||||||
|
|
||||||
|
#for(importClass : table.buildImports())
|
||||||
|
import #(importClass);
|
||||||
|
#end
|
||||||
|
#if(withActiveRecord)
|
||||||
|
import com.mybatisflex.core.activerecord.Model;
|
||||||
|
#end
|
||||||
|
#if(withSwagger && swaggerVersion.getName() == "FOX")
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
#end
|
||||||
|
#if(withSwagger && swaggerVersion.getName() == "DOC")
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
#end
|
||||||
|
#if(withLombok)
|
||||||
|
#if(withActiveRecord)
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
#else
|
||||||
|
import lombok.*;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
#end
|
||||||
|
#end
|
||||||
|
|
||||||
|
/**
|
||||||
|
* #(table.getComment()) 实体类。
|
||||||
|
*
|
||||||
|
* @author #(javadocConfig.getAuthor())
|
||||||
|
* @since #(javadocConfig.getSince())
|
||||||
|
*/
|
||||||
|
#if(withLombok)
|
||||||
|
#if(withActiveRecord)
|
||||||
|
@Accessors(chain = true)
|
||||||
|
@Data(staticConstructor = "create")
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
#else
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper=false)
|
||||||
|
@Builder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
@Accessors(chain = true)
|
||||||
|
#end
|
||||||
|
#end
|
||||||
|
#if(withSwagger && swaggerVersion.getName() == "FOX")
|
||||||
|
@ApiModel("#(table.getComment())")
|
||||||
|
#end
|
||||||
|
#if(withSwagger && swaggerVersion.getName() == "DOC")
|
||||||
|
@Schema(description = "#(table.getComment())")
|
||||||
|
#end
|
||||||
|
public class #(entityClassName)Bo#if(withActiveRecord) extends Model<#(entityClassName)>#else#(table.buildImplements())#end {
|
||||||
|
|
||||||
|
#for(column : table.columns)
|
||||||
|
#set(comment = javadocConfig.formatColumnComment(column.comment))
|
||||||
|
#if(isNotBlank(comment))
|
||||||
|
/**
|
||||||
|
* #(comment)
|
||||||
|
*/
|
||||||
|
#end
|
||||||
|
#if(isNotBlank(annotations))
|
||||||
|
#(annotations)
|
||||||
|
#end
|
||||||
|
#if(withSwagger && swaggerVersion.getName() == "FOX")
|
||||||
|
@ApiModelProperty("#(column.comment)")
|
||||||
|
#end
|
||||||
|
#if(withSwagger && swaggerVersion.getName() == "DOC")
|
||||||
|
@Schema(description = "#(column.comment)")
|
||||||
|
#end
|
||||||
|
private #(column.propertySimpleType) #(column.property)#if(isNotBlank(column.propertyDefaultValue)) = #(column.propertyDefaultValue)#end;
|
||||||
|
|
||||||
|
#end
|
||||||
|
#if(!withLombok)
|
||||||
|
#if(withActiveRecord)
|
||||||
|
public static #(entityClassName) create() {
|
||||||
|
return new #(entityClassName)();
|
||||||
|
}
|
||||||
|
|
||||||
|
#end
|
||||||
|
#for(column: table.columns)
|
||||||
|
public #(column.propertySimpleType) #(column.getterMethod())() {
|
||||||
|
return #(column.property);
|
||||||
|
}
|
||||||
|
|
||||||
|
#if(withActiveRecord)
|
||||||
|
public #(entityClassName) #(column.setterMethod())(#(column.propertySimpleType) #(column.property)) {
|
||||||
|
this.#(column.property) = #(column.property);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
public void #(column.setterMethod())(#(column.propertySimpleType) #(column.property)) {
|
||||||
|
this.#(column.property) = #(column.property);
|
||||||
|
}
|
||||||
|
#end
|
||||||
|
|
||||||
|
#end
|
||||||
|
#end}
|
||||||
163
Cpop-Generator/src/main/resources/template.enjoy/controller.tpl
Normal file
163
Cpop-Generator/src/main/resources/template.enjoy/controller.tpl
Normal file
@ -0,0 +1,163 @@
|
|||||||
|
#set(tableComment = table.getComment())
|
||||||
|
#set(entityClassName = table.buildEntityClassName())
|
||||||
|
#set(entityVarName = firstCharToLowerCase(entityClassName))
|
||||||
|
#set(serviceVarName = firstCharToLowerCase(table.buildServiceClassName()))
|
||||||
|
package #(packageConfig.controllerPackage);
|
||||||
|
|
||||||
|
import com.mybatisflex.core.paginate.Page;
|
||||||
|
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PutMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import #(packageConfig.entityPackage).#(entityClassName);
|
||||||
|
import #(packageConfig.servicePackage).#(table.buildServiceClassName());
|
||||||
|
#if(controllerConfig.restStyle)
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
#else
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
|
#end
|
||||||
|
#if(controllerConfig.superClass != null)
|
||||||
|
import #(controllerConfig.buildSuperClassImport());
|
||||||
|
#end
|
||||||
|
#if(withSwagger && swaggerVersion.getName() == "FOX")
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import io.swagger.annotations.ApiParam;
|
||||||
|
#end
|
||||||
|
#if(withSwagger && swaggerVersion.getName() == "DOC")
|
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
|
import io.swagger.v3.oas.annotations.Parameter;
|
||||||
|
#end
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* #(tableComment) 控制层。
|
||||||
|
*
|
||||||
|
* @author #(javadocConfig.getAuthor())
|
||||||
|
* @since #(javadocConfig.getSince())
|
||||||
|
*/
|
||||||
|
#if(controllerConfig.restStyle)
|
||||||
|
@RestController
|
||||||
|
#else
|
||||||
|
@Controller
|
||||||
|
#end
|
||||||
|
#if(withSwagger && swaggerVersion.getName() == "FOX")
|
||||||
|
@Api(tags = "#(tableComment)接口")
|
||||||
|
#end
|
||||||
|
#if(withSwagger && swaggerVersion.getName() == "DOC")
|
||||||
|
@Tag(name = "#(tableComment)接口")
|
||||||
|
#end
|
||||||
|
@RequestMapping("/#(firstCharToLowerCase(entityClassName))")
|
||||||
|
public class #(table.buildControllerClassName()) #if(controllerConfig.superClass)extends #(controllerConfig.buildSuperClassName()) #end {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private #(table.buildServiceClassName()) #(serviceVarName);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加#(tableComment)。
|
||||||
|
*
|
||||||
|
* @param #(entityVarName) #(tableComment)
|
||||||
|
* @return {@code true} 添加成功,{@code false} 添加失败
|
||||||
|
*/
|
||||||
|
@PostMapping("save")
|
||||||
|
#if(withSwagger && swaggerVersion.getName() == "FOX")
|
||||||
|
@ApiOperation("保存#(tableComment)")
|
||||||
|
#end
|
||||||
|
#if(withSwagger && swaggerVersion.getName() == "DOC")
|
||||||
|
@Operation(summary="保存#(tableComment)")
|
||||||
|
#end
|
||||||
|
public boolean save(@RequestBody #if(withSwagger && swaggerVersion.getName() == "FOX")@ApiParam("#(tableComment)") #end #if(withSwagger && swaggerVersion.getName() == "DOC")@Parameter(description="#(tableComment)")#end #(entityClassName) #(entityVarName)) {
|
||||||
|
return #(serviceVarName).save(#(entityVarName));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据主键删除#(tableComment)。
|
||||||
|
*
|
||||||
|
* @param id 主键
|
||||||
|
* @return {@code true} 删除成功,{@code false} 删除失败
|
||||||
|
*/
|
||||||
|
@DeleteMapping("remove/{id}")
|
||||||
|
#if(withSwagger && swaggerVersion.getName() == "FOX")
|
||||||
|
@ApiOperation("根据主键#(tableComment)")
|
||||||
|
#end
|
||||||
|
#if(withSwagger && swaggerVersion.getName() == "DOC")
|
||||||
|
@Operation(summary="根据主键#(tableComment)")
|
||||||
|
#end
|
||||||
|
public boolean remove(@PathVariable #if(withSwagger && swaggerVersion.getName() == "FOX")@ApiParam("#(tableComment)主键") #end #if(withSwagger && swaggerVersion.getName() == "DOC")@Parameter(description="#(tableComment)主键")#end Serializable id) {
|
||||||
|
return #(serviceVarName).removeById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据主键更新#(tableComment)。
|
||||||
|
*
|
||||||
|
* @param #(entityVarName) #(tableComment)
|
||||||
|
* @return {@code true} 更新成功,{@code false} 更新失败
|
||||||
|
*/
|
||||||
|
@PutMapping("update")
|
||||||
|
#if(withSwagger && swaggerVersion.getName() == "FOX")
|
||||||
|
@ApiOperation("根据主键更新#(tableComment)")
|
||||||
|
#end
|
||||||
|
#if(withSwagger && swaggerVersion.getName() == "DOC")
|
||||||
|
@Operation(summary="根据主键更新#(tableComment)")
|
||||||
|
#end
|
||||||
|
public boolean update(@RequestBody #if(withSwagger && swaggerVersion.getName() == "FOX")@ApiParam("#(tableComment)主键") #end #if(withSwagger && swaggerVersion.getName() == "DOC")@Parameter(description="#(tableComment)主键")#end#(entityClassName) #(entityVarName)) {
|
||||||
|
return #(serviceVarName).updateById(#(entityVarName));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询所有#(tableComment)。
|
||||||
|
*
|
||||||
|
* @return 所有数据
|
||||||
|
*/
|
||||||
|
@GetMapping("list")
|
||||||
|
#if(withSwagger && swaggerVersion.getName() == "FOX")
|
||||||
|
@ApiOperation("查询所有#(tableComment)")
|
||||||
|
#end
|
||||||
|
#if(withSwagger && swaggerVersion.getName() == "DOC")
|
||||||
|
@Operation(summary="查询所有#(tableComment)")
|
||||||
|
#end
|
||||||
|
public List<#(entityClassName)> list() {
|
||||||
|
return #(serviceVarName).list();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据#(tableComment)主键获取详细信息。
|
||||||
|
*
|
||||||
|
* @param id #(tableComment)主键
|
||||||
|
* @return #(tableComment)详情
|
||||||
|
*/
|
||||||
|
@GetMapping("getInfo/{id}")
|
||||||
|
#if(withSwagger && swaggerVersion.getName() == "FOX")
|
||||||
|
@ApiOperation("根据主键获取#(tableComment)")
|
||||||
|
#end
|
||||||
|
#if(withSwagger && swaggerVersion.getName() == "DOC")
|
||||||
|
@Operation(summary="根据主键获取#(tableComment)")
|
||||||
|
#end
|
||||||
|
public #(entityClassName) getInfo(@PathVariable #if(withSwagger && swaggerVersion.getName() == "FOX")@ApiParam("#(tableComment)主键") #if(withSwagger && swaggerVersion.getName() == "DOC")@Parameter(description="#(tableComment)主键")#end#end Serializable id) {
|
||||||
|
return #(serviceVarName).getById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页查询#(tableComment)。
|
||||||
|
*
|
||||||
|
* @param page 分页对象
|
||||||
|
* @return 分页对象
|
||||||
|
*/
|
||||||
|
@GetMapping("page")
|
||||||
|
#if(withSwagger && swaggerVersion.getName() == "FOX")
|
||||||
|
@ApiOperation("分页查询#(tableComment)")
|
||||||
|
#end
|
||||||
|
#if(withSwagger && swaggerVersion.getName() == "DOC")
|
||||||
|
@Operation(summary="分页查询#(tableComment)")
|
||||||
|
#end
|
||||||
|
public Page<#(entityClassName)> page(#if(withSwagger && swaggerVersion.getName() == "FOX")@ApiParam("分页信息") #end #if(withSwagger && swaggerVersion.getName() == "DOC")@Parameter(description="分页信息")#end Page<#(entityClassName)> page) {
|
||||||
|
return #(serviceVarName).page(page);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
91
Cpop-Generator/src/main/resources/template.enjoy/dto.tpl
Normal file
91
Cpop-Generator/src/main/resources/template.enjoy/dto.tpl
Normal file
@ -0,0 +1,91 @@
|
|||||||
|
#set(withLombok = entityConfig.isWithLombok())
|
||||||
|
#set(withSwagger = entityConfig.isWithSwagger())
|
||||||
|
#set(swaggerVersion = entityConfig.getSwaggerVersion())
|
||||||
|
#set(withActiveRecord = entityConfig.isWithActiveRecord())
|
||||||
|
#set(entityClassName = table.buildEntityClassName())
|
||||||
|
package #(packageConfig.basePackage).dto;
|
||||||
|
|
||||||
|
#for(importClass : table.buildImports())
|
||||||
|
import #(importClass);
|
||||||
|
#end
|
||||||
|
#if(withActiveRecord)
|
||||||
|
import com.mybatisflex.core.activerecord.Model;
|
||||||
|
#end
|
||||||
|
#if(withSwagger && swaggerVersion.getName() == "FOX")
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
#end
|
||||||
|
#if(withSwagger && swaggerVersion.getName() == "DOC")
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
#end
|
||||||
|
#if(withLombok)
|
||||||
|
#if(withActiveRecord)
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
#else
|
||||||
|
import lombok.*;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
#end
|
||||||
|
#end
|
||||||
|
|
||||||
|
/**
|
||||||
|
* #(table.getComment()) 实体类。
|
||||||
|
*
|
||||||
|
* @author #(javadocConfig.getAuthor())
|
||||||
|
* @since #(javadocConfig.getSince())
|
||||||
|
*/
|
||||||
|
#if(withLombok)
|
||||||
|
#if(withActiveRecord)
|
||||||
|
@Accessors(chain = true)
|
||||||
|
@Data(staticConstructor = "create")
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
#else
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper=false)
|
||||||
|
@Builder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
@Accessors(chain = true)
|
||||||
|
#end
|
||||||
|
#end
|
||||||
|
public class #(entityClassName)Dto#if(withActiveRecord) extends Model<#(entityClassName)>#else#(table.buildImplements())#end {
|
||||||
|
|
||||||
|
#for(column : table.columns)
|
||||||
|
#set(comment = javadocConfig.formatColumnComment(column.comment))
|
||||||
|
#if(isNotBlank(comment))
|
||||||
|
/**
|
||||||
|
* #(comment)
|
||||||
|
*/
|
||||||
|
#end
|
||||||
|
#if(isNotBlank(annotations))
|
||||||
|
#(annotations)
|
||||||
|
#end
|
||||||
|
private #(column.propertySimpleType) #(column.property)#if(isNotBlank(column.propertyDefaultValue)) = #(column.propertyDefaultValue)#end;
|
||||||
|
|
||||||
|
#end
|
||||||
|
#if(!withLombok)
|
||||||
|
#if(withActiveRecord)
|
||||||
|
public static #(entityClassName) create() {
|
||||||
|
return new #(entityClassName)();
|
||||||
|
}
|
||||||
|
|
||||||
|
#end
|
||||||
|
#for(column: table.columns)
|
||||||
|
public #(column.propertySimpleType) #(column.getterMethod())() {
|
||||||
|
return #(column.property);
|
||||||
|
}
|
||||||
|
|
||||||
|
#if(withActiveRecord)
|
||||||
|
public #(entityClassName) #(column.setterMethod())(#(column.propertySimpleType) #(column.property)) {
|
||||||
|
this.#(column.property) = #(column.property);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
public void #(column.setterMethod())(#(column.propertySimpleType) #(column.property)) {
|
||||||
|
this.#(column.property) = #(column.property);
|
||||||
|
}
|
||||||
|
#end
|
||||||
|
|
||||||
|
#end
|
||||||
|
#end}
|
||||||
95
Cpop-Generator/src/main/resources/template.enjoy/entity.tpl
Normal file
95
Cpop-Generator/src/main/resources/template.enjoy/entity.tpl
Normal file
@ -0,0 +1,95 @@
|
|||||||
|
#set(withLombok = entityConfig.isWithLombok())
|
||||||
|
#set(withSwagger = entityConfig.isWithSwagger())
|
||||||
|
#set(swaggerVersion = entityConfig.getSwaggerVersion())
|
||||||
|
#set(withActiveRecord = entityConfig.isWithActiveRecord())
|
||||||
|
#set(entityClassName = table.buildEntityClassName())
|
||||||
|
package #(packageConfig.entityPackage);
|
||||||
|
|
||||||
|
#for(importClass : table.buildImports())
|
||||||
|
import #(importClass);
|
||||||
|
#end
|
||||||
|
#if(withActiveRecord)
|
||||||
|
import com.mybatisflex.core.activerecord.Model;
|
||||||
|
#end
|
||||||
|
#if(withSwagger && swaggerVersion.getName() == "FOX")
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
#end
|
||||||
|
#if(withSwagger && swaggerVersion.getName() == "DOC")
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
#end
|
||||||
|
#if(withLombok)
|
||||||
|
#if(withActiveRecord)
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
#else
|
||||||
|
import lombok.*;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
#end
|
||||||
|
#end
|
||||||
|
|
||||||
|
/**
|
||||||
|
* #(table.getComment()) 实体类。
|
||||||
|
*
|
||||||
|
* @author #(javadocConfig.getAuthor())
|
||||||
|
* @since #(javadocConfig.getSince())
|
||||||
|
*/
|
||||||
|
#if(withLombok)
|
||||||
|
#if(withActiveRecord)
|
||||||
|
@Accessors(chain = true)
|
||||||
|
@Data(staticConstructor = "create")
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
#else
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper=false)
|
||||||
|
@Builder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
@Accessors(chain = true)
|
||||||
|
#end
|
||||||
|
#end
|
||||||
|
#(table.buildTableAnnotation())
|
||||||
|
public class #(entityClassName)#if(withActiveRecord) extends Model<#(entityClassName)>#else#(table.buildExtends())#(table.buildImplements())#end {
|
||||||
|
|
||||||
|
#for(column : table.columns)
|
||||||
|
#if(column.property != "createTime" && column.property != "createUserId" && column.property != "updateTime" && column.property != "updateUserId")
|
||||||
|
#set(comment = javadocConfig.formatColumnComment(column.comment))
|
||||||
|
#if(isNotBlank(comment))
|
||||||
|
/**
|
||||||
|
* #(comment)
|
||||||
|
*/
|
||||||
|
#end
|
||||||
|
#set(annotations = column.buildAnnotations())
|
||||||
|
#if(isNotBlank(annotations))
|
||||||
|
#(annotations)
|
||||||
|
#end
|
||||||
|
private #(column.propertySimpleType) #(column.property)#if(isNotBlank(column.propertyDefaultValue)) = #(column.propertyDefaultValue)#end;
|
||||||
|
#end
|
||||||
|
|
||||||
|
#end
|
||||||
|
#if(!withLombok)
|
||||||
|
#if(withActiveRecord)
|
||||||
|
public static #(entityClassName) create() {
|
||||||
|
return new #(entityClassName)();
|
||||||
|
}
|
||||||
|
|
||||||
|
#end
|
||||||
|
#for(column: table.columns)
|
||||||
|
public #(column.propertySimpleType) #(column.getterMethod())() {
|
||||||
|
return #(column.property);
|
||||||
|
}
|
||||||
|
|
||||||
|
#if(withActiveRecord)
|
||||||
|
public #(entityClassName) #(column.setterMethod())(#(column.propertySimpleType) #(column.property)) {
|
||||||
|
this.#(column.property) = #(column.property);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
public void #(column.setterMethod())(#(column.propertySimpleType) #(column.property)) {
|
||||||
|
this.#(column.property) = #(column.property);
|
||||||
|
}
|
||||||
|
#end
|
||||||
|
|
||||||
|
#end
|
||||||
|
#end}
|
||||||
20
Cpop-Generator/src/main/resources/template.enjoy/mapper.tpl
Normal file
20
Cpop-Generator/src/main/resources/template.enjoy/mapper.tpl
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
package #(packageConfig.mapperPackage);
|
||||||
|
|
||||||
|
#if(mapperConfig.isMapperAnnotation())
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
#end
|
||||||
|
import #(mapperConfig.buildSuperClassImport());
|
||||||
|
import #(packageConfig.entityPackage).#(table.buildEntityClassName());
|
||||||
|
|
||||||
|
/**
|
||||||
|
* #(table.getComment()) 映射层。
|
||||||
|
*
|
||||||
|
* @author #(javadocConfig.getAuthor())
|
||||||
|
* @since #(javadocConfig.getSince())
|
||||||
|
*/
|
||||||
|
#if(mapperConfig.isMapperAnnotation())
|
||||||
|
@Mapper
|
||||||
|
#end
|
||||||
|
public interface #(table.buildMapperClassName()) extends #(mapperConfig.buildSuperClassName())<#(table.buildEntityClassName())> {
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,7 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE mapper
|
||||||
|
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="#(packageConfig.mapperPackage).#(table.buildMapperClassName())">
|
||||||
|
|
||||||
|
</mapper>
|
||||||
@ -0,0 +1,7 @@
|
|||||||
|
/**
|
||||||
|
* #(packageComment)
|
||||||
|
*
|
||||||
|
* @author #(javadocConfig.getAuthor())
|
||||||
|
* @since #(javadocConfig.getSince())
|
||||||
|
*/
|
||||||
|
package #(packageName);
|
||||||
103
Cpop-Generator/src/main/resources/template.enjoy/pageBo.tpl
Normal file
103
Cpop-Generator/src/main/resources/template.enjoy/pageBo.tpl
Normal file
@ -0,0 +1,103 @@
|
|||||||
|
#set(withLombok = entityConfig.isWithLombok())
|
||||||
|
#set(withSwagger = entityConfig.isWithSwagger())
|
||||||
|
#set(swaggerVersion = entityConfig.getSwaggerVersion())
|
||||||
|
#set(withActiveRecord = entityConfig.isWithActiveRecord())
|
||||||
|
#set(entityClassName = table.buildEntityClassName())
|
||||||
|
package #(packageConfig.basePackage).bo;
|
||||||
|
|
||||||
|
#for(importClass : table.buildImports())
|
||||||
|
import #(importClass);
|
||||||
|
#end
|
||||||
|
#if(withActiveRecord)
|
||||||
|
import com.mybatisflex.core.activerecord.Model;
|
||||||
|
#end
|
||||||
|
#if(withSwagger && swaggerVersion.getName() == "FOX")
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
#end
|
||||||
|
#if(withSwagger && swaggerVersion.getName() == "DOC")
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
#end
|
||||||
|
#if(withLombok)
|
||||||
|
#if(withActiveRecord)
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
#else
|
||||||
|
import lombok.*;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
#end
|
||||||
|
#end
|
||||||
|
|
||||||
|
/**
|
||||||
|
* #(table.getComment()) 实体类。
|
||||||
|
*
|
||||||
|
* @author #(javadocConfig.getAuthor())
|
||||||
|
* @since #(javadocConfig.getSince())
|
||||||
|
*/
|
||||||
|
#if(withLombok)
|
||||||
|
#if(withActiveRecord)
|
||||||
|
@Accessors(chain = true)
|
||||||
|
@Data(staticConstructor = "create")
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
#else
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper=false)
|
||||||
|
@Builder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
@Accessors(chain = true)
|
||||||
|
#end
|
||||||
|
#end
|
||||||
|
#if(withSwagger && swaggerVersion.getName() == "FOX")
|
||||||
|
@ApiModel("#(table.getComment())")
|
||||||
|
#end
|
||||||
|
#if(withSwagger && swaggerVersion.getName() == "DOC")
|
||||||
|
@Schema(description = "#(table.getComment())")
|
||||||
|
#end
|
||||||
|
public class #(entityClassName)PageBo#if(withActiveRecord) extends Model<#(entityClassName)>#else#(table.buildImplements())#end {
|
||||||
|
|
||||||
|
#for(column : table.columns)
|
||||||
|
#set(comment = javadocConfig.formatColumnComment(column.comment))
|
||||||
|
#if(isNotBlank(comment))
|
||||||
|
/**
|
||||||
|
* #(comment)
|
||||||
|
*/
|
||||||
|
#end
|
||||||
|
#if(isNotBlank(annotations))
|
||||||
|
#(annotations)
|
||||||
|
#end
|
||||||
|
#if(withSwagger && swaggerVersion.getName() == "FOX")
|
||||||
|
@ApiModelProperty("#(column.comment)")
|
||||||
|
#end
|
||||||
|
#if(withSwagger && swaggerVersion.getName() == "DOC")
|
||||||
|
@Schema(description = "#(column.comment)")
|
||||||
|
#end
|
||||||
|
private #(column.propertySimpleType) #(column.property)#if(isNotBlank(column.propertyDefaultValue)) = #(column.propertyDefaultValue)#end;
|
||||||
|
|
||||||
|
#end
|
||||||
|
#if(!withLombok)
|
||||||
|
#if(withActiveRecord)
|
||||||
|
public static #(entityClassName) create() {
|
||||||
|
return new #(entityClassName)();
|
||||||
|
}
|
||||||
|
|
||||||
|
#end
|
||||||
|
#for(column: table.columns)
|
||||||
|
public #(column.propertySimpleType) #(column.getterMethod())() {
|
||||||
|
return #(column.property);
|
||||||
|
}
|
||||||
|
|
||||||
|
#if(withActiveRecord)
|
||||||
|
public #(entityClassName) #(column.setterMethod())(#(column.propertySimpleType) #(column.property)) {
|
||||||
|
this.#(column.property) = #(column.property);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
public void #(column.setterMethod())(#(column.propertySimpleType) #(column.property)) {
|
||||||
|
this.#(column.property) = #(column.property);
|
||||||
|
}
|
||||||
|
#end
|
||||||
|
|
||||||
|
#end
|
||||||
|
#end}
|
||||||
103
Cpop-Generator/src/main/resources/template.enjoy/pageVo.tpl
Normal file
103
Cpop-Generator/src/main/resources/template.enjoy/pageVo.tpl
Normal file
@ -0,0 +1,103 @@
|
|||||||
|
#set(withLombok = entityConfig.isWithLombok())
|
||||||
|
#set(withSwagger = entityConfig.isWithSwagger())
|
||||||
|
#set(swaggerVersion = entityConfig.getSwaggerVersion())
|
||||||
|
#set(withActiveRecord = entityConfig.isWithActiveRecord())
|
||||||
|
#set(entityClassName = table.buildEntityClassName())
|
||||||
|
package #(packageConfig.basePackage).vo;
|
||||||
|
|
||||||
|
#for(importClass : table.buildImports())
|
||||||
|
import #(importClass);
|
||||||
|
#end
|
||||||
|
#if(withActiveRecord)
|
||||||
|
import com.mybatisflex.core.activerecord.Model;
|
||||||
|
#end
|
||||||
|
#if(withSwagger && swaggerVersion.getName() == "FOX")
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
#end
|
||||||
|
#if(withSwagger && swaggerVersion.getName() == "DOC")
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
#end
|
||||||
|
#if(withLombok)
|
||||||
|
#if(withActiveRecord)
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
#else
|
||||||
|
import lombok.*;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
#end
|
||||||
|
#end
|
||||||
|
|
||||||
|
/**
|
||||||
|
* #(table.getComment()) 实体类。
|
||||||
|
*
|
||||||
|
* @author #(javadocConfig.getAuthor())
|
||||||
|
* @since #(javadocConfig.getSince())
|
||||||
|
*/
|
||||||
|
#if(withLombok)
|
||||||
|
#if(withActiveRecord)
|
||||||
|
@Accessors(chain = true)
|
||||||
|
@Data(staticConstructor = "create")
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
#else
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper=false)
|
||||||
|
@Builder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
@Accessors(chain = true)
|
||||||
|
#end
|
||||||
|
#end
|
||||||
|
#if(withSwagger && swaggerVersion.getName() == "FOX")
|
||||||
|
@ApiModel("#(table.getComment())")
|
||||||
|
#end
|
||||||
|
#if(withSwagger && swaggerVersion.getName() == "DOC")
|
||||||
|
@Schema(description = "#(table.getComment())")
|
||||||
|
#end
|
||||||
|
public class #(entityClassName)PageVo#if(withActiveRecord) extends Model<#(entityClassName)>#else#(table.buildImplements())#end {
|
||||||
|
|
||||||
|
#for(column : table.columns)
|
||||||
|
#set(comment = javadocConfig.formatColumnComment(column.comment))
|
||||||
|
#if(isNotBlank(comment))
|
||||||
|
/**
|
||||||
|
* #(comment)
|
||||||
|
*/
|
||||||
|
#end
|
||||||
|
#if(isNotBlank(annotations))
|
||||||
|
#(annotations)
|
||||||
|
#end
|
||||||
|
#if(withSwagger && swaggerVersion.getName() == "FOX")
|
||||||
|
@ApiModelProperty("#(column.comment)")
|
||||||
|
#end
|
||||||
|
#if(withSwagger && swaggerVersion.getName() == "DOC")
|
||||||
|
@Schema(description = "#(column.comment)")
|
||||||
|
#end
|
||||||
|
private #(column.propertySimpleType) #(column.property)#if(isNotBlank(column.propertyDefaultValue)) = #(column.propertyDefaultValue)#end;
|
||||||
|
|
||||||
|
#end
|
||||||
|
#if(!withLombok)
|
||||||
|
#if(withActiveRecord)
|
||||||
|
public static #(entityClassName) create() {
|
||||||
|
return new #(entityClassName)();
|
||||||
|
}
|
||||||
|
|
||||||
|
#end
|
||||||
|
#for(column: table.columns)
|
||||||
|
public #(column.propertySimpleType) #(column.getterMethod())() {
|
||||||
|
return #(column.property);
|
||||||
|
}
|
||||||
|
|
||||||
|
#if(withActiveRecord)
|
||||||
|
public #(entityClassName) #(column.setterMethod())(#(column.propertySimpleType) #(column.property)) {
|
||||||
|
this.#(column.property) = #(column.property);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
public void #(column.setterMethod())(#(column.propertySimpleType) #(column.property)) {
|
||||||
|
this.#(column.property) = #(column.property);
|
||||||
|
}
|
||||||
|
#end
|
||||||
|
|
||||||
|
#end
|
||||||
|
#end}
|
||||||
14
Cpop-Generator/src/main/resources/template.enjoy/service.tpl
Normal file
14
Cpop-Generator/src/main/resources/template.enjoy/service.tpl
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
package #(packageConfig.servicePackage);
|
||||||
|
|
||||||
|
import #(serviceConfig.buildSuperClassImport());
|
||||||
|
import #(packageConfig.entityPackage).#(table.buildEntityClassName());
|
||||||
|
|
||||||
|
/**
|
||||||
|
* #(table.getComment()) 服务层。
|
||||||
|
*
|
||||||
|
* @author #(javadocConfig.getAuthor())
|
||||||
|
* @since #(javadocConfig.getSince())
|
||||||
|
*/
|
||||||
|
public interface #(table.buildServiceClassName()) extends #(serviceConfig.buildSuperClassName())<#(table.buildEntityClassName())> {
|
||||||
|
|
||||||
|
}
|
||||||
124
Cpop-Generator/src/main/resources/template.enjoy/serviceImpl.tpl
Normal file
124
Cpop-Generator/src/main/resources/template.enjoy/serviceImpl.tpl
Normal file
@ -0,0 +1,124 @@
|
|||||||
|
#set(isCacheExample = serviceImplConfig.cacheExample)
|
||||||
|
#set(primaryKey = table.getPrimaryKey())
|
||||||
|
#set(entityClassName = table.buildEntityClassName())
|
||||||
|
package #(packageConfig.serviceImplPackage);
|
||||||
|
|
||||||
|
import #(serviceImplConfig.buildSuperClassImport());
|
||||||
|
import #(packageConfig.entityPackage).#(table.buildEntityClassName());
|
||||||
|
import #(packageConfig.mapperPackage).#(table.buildMapperClassName());
|
||||||
|
import #(packageConfig.servicePackage).#(table.buildServiceClassName());
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
#if(isCacheExample)
|
||||||
|
import com.mybatisflex.core.paginate.Page;
|
||||||
|
import com.mybatisflex.core.query.QueryWrapper;
|
||||||
|
import org.springframework.cache.annotation.Cacheable;
|
||||||
|
import org.springframework.cache.annotation.CacheConfig;
|
||||||
|
import org.springframework.cache.annotation.CacheEvict;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.List;
|
||||||
|
#end
|
||||||
|
|
||||||
|
/**
|
||||||
|
* #(table.getComment()) 服务层实现。
|
||||||
|
*
|
||||||
|
* @author #(javadocConfig.getAuthor())
|
||||||
|
* @since #(javadocConfig.getSince())
|
||||||
|
*/
|
||||||
|
@Service("#(firstCharToLowerCase(entityClassName))Service")
|
||||||
|
#if(isCacheExample)
|
||||||
|
@CacheConfig(cacheNames = "#(firstCharToLowerCase(entityClassName))")
|
||||||
|
#end
|
||||||
|
public class #(table.buildServiceImplClassName()) extends #(serviceImplConfig.buildSuperClassName())<#(table.buildMapperClassName()), #(table.buildEntityClassName())> implements #(table.buildServiceClassName()) {
|
||||||
|
|
||||||
|
#if(isCacheExample)
|
||||||
|
@Override
|
||||||
|
@CacheEvict(allEntries = true)
|
||||||
|
public boolean remove(QueryWrapper query) {
|
||||||
|
return super.remove(query);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@CacheEvict(key = "#id")
|
||||||
|
public boolean removeById(Serializable id) {
|
||||||
|
return super.removeById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@CacheEvict(allEntries = true)
|
||||||
|
public boolean removeByIds(Collection<? extends Serializable> ids) {
|
||||||
|
return super.removeByIds(ids);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@CacheEvict(allEntries = true)
|
||||||
|
public boolean update(#(entityClassName) entity, QueryWrapper query) {
|
||||||
|
return super.update(entity, query);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@CacheEvict(key = "#entity.#(primaryKey)")
|
||||||
|
public boolean updateById(#(entityClassName) entity, boolean ignoreNulls) {
|
||||||
|
return super.updateById(entity, ignoreNulls);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@CacheEvict(allEntries = true)
|
||||||
|
public boolean updateBatch(Collection<#(entityClassName)> entities, int batchSize) {
|
||||||
|
return super.updateBatch(entities, batchSize);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Cacheable(key = "#id")
|
||||||
|
public #(entityClassName) getById(Serializable id) {
|
||||||
|
return super.getById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Cacheable(key = "#root.methodName + ':' + #query.toSQL()")
|
||||||
|
public #(entityClassName) getOne(QueryWrapper query) {
|
||||||
|
return super.getOne(query);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Cacheable(key = "#root.methodName + ':' + #query.toSQL()")
|
||||||
|
public <R> R getOneAs(QueryWrapper query, Class<R> asType) {
|
||||||
|
return super.getOneAs(query, asType);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Cacheable(key = "#root.methodName + ':' + #query.toSQL()")
|
||||||
|
public List<#(entityClassName)> list(QueryWrapper query) {
|
||||||
|
return super.list(query);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Cacheable(key = "#root.methodName + ':' + #query.toSQL()")
|
||||||
|
public <R> List<R> listAs(QueryWrapper query, Class<R> asType) {
|
||||||
|
return super.listAs(query, asType);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated 无法通过注解进行缓存操作。
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
@Deprecated
|
||||||
|
public List<#(entityClassName)> listByIds(Collection<? extends Serializable> ids) {
|
||||||
|
return super.listByIds(ids);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Cacheable(key = "#root.methodName + ':' + #query.toSQL()")
|
||||||
|
public long count(QueryWrapper query) {
|
||||||
|
return super.count(query);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Cacheable(key = "#root.methodName + ':' + #page.getPageSize() + ':' + #page.getPageNumber() + ':' + #query.toSQL()")
|
||||||
|
public <R> Page<R> pageAs(Page<R> page, QueryWrapper query, Class<R> asType) {
|
||||||
|
return super.pageAs(page, query, asType);
|
||||||
|
}
|
||||||
|
|
||||||
|
#end
|
||||||
|
}
|
||||||
@ -0,0 +1,40 @@
|
|||||||
|
#set(tableDefClassName = table.buildTableDefClassName())
|
||||||
|
#set(schema = table.schema == null ? "" : table.schema)
|
||||||
|
package #(packageConfig.tableDefPackage);
|
||||||
|
|
||||||
|
import com.mybatisflex.core.query.QueryColumn;
|
||||||
|
import com.mybatisflex.core.table.TableDef;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* #(table.getComment()) 表定义层。
|
||||||
|
*
|
||||||
|
* @author #(javadocConfig.getAuthor())
|
||||||
|
* @since #(javadocConfig.getSince())
|
||||||
|
*/
|
||||||
|
public class #(tableDefClassName) extends TableDef {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* #(table.getComment())
|
||||||
|
*/
|
||||||
|
public static final #(tableDefClassName) #(tableDefConfig.buildFieldName(table.buildEntityClassName() + tableDefConfig.instanceSuffix)) = new #(tableDefClassName)();
|
||||||
|
|
||||||
|
#for(column: table.getSortedColumns())
|
||||||
|
#(column.buildComment())
|
||||||
|
public final QueryColumn #(tableDefConfig.buildFieldName(column.property)) = new QueryColumn(this, "#(column.name)");
|
||||||
|
|
||||||
|
#end
|
||||||
|
/**
|
||||||
|
* 所有字段。
|
||||||
|
*/
|
||||||
|
public final QueryColumn #(tableDefConfig.buildFieldName("allColumns")) = new QueryColumn(this, "*");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 默认字段,不包含逻辑删除或者 large 等字段。
|
||||||
|
*/
|
||||||
|
public final QueryColumn[] #(tableDefConfig.buildFieldName("defaultColumns")) = new QueryColumn[]{#for(column: table.columns)#if(column.isDefaultColumn())#(tableDefConfig.buildFieldName(column.property))#if(for.index + 1 != for.size), #end#end#end};
|
||||||
|
|
||||||
|
public #(tableDefClassName)() {
|
||||||
|
super("#(schema)", "#(table.name)");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
103
Cpop-Generator/src/main/resources/template.enjoy/vo.tpl
Normal file
103
Cpop-Generator/src/main/resources/template.enjoy/vo.tpl
Normal file
@ -0,0 +1,103 @@
|
|||||||
|
#set(withLombok = entityConfig.isWithLombok())
|
||||||
|
#set(withSwagger = entityConfig.isWithSwagger())
|
||||||
|
#set(swaggerVersion = entityConfig.getSwaggerVersion())
|
||||||
|
#set(withActiveRecord = entityConfig.isWithActiveRecord())
|
||||||
|
#set(entityClassName = table.buildEntityClassName())
|
||||||
|
package #(packageConfig.basePackage).vo;
|
||||||
|
|
||||||
|
#for(importClass : table.buildImports())
|
||||||
|
import #(importClass);
|
||||||
|
#end
|
||||||
|
#if(withActiveRecord)
|
||||||
|
import com.mybatisflex.core.activerecord.Model;
|
||||||
|
#end
|
||||||
|
#if(withSwagger && swaggerVersion.getName() == "FOX")
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
#end
|
||||||
|
#if(withSwagger && swaggerVersion.getName() == "DOC")
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
#end
|
||||||
|
#if(withLombok)
|
||||||
|
#if(withActiveRecord)
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
#else
|
||||||
|
import lombok.*;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
#end
|
||||||
|
#end
|
||||||
|
|
||||||
|
/**
|
||||||
|
* #(table.getComment()) 实体类。
|
||||||
|
*
|
||||||
|
* @author #(javadocConfig.getAuthor())
|
||||||
|
* @since #(javadocConfig.getSince())
|
||||||
|
*/
|
||||||
|
#if(withLombok)
|
||||||
|
#if(withActiveRecord)
|
||||||
|
@Accessors(chain = true)
|
||||||
|
@Data(staticConstructor = "create")
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
#else
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper=false)
|
||||||
|
@Builder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
@Accessors(chain = true)
|
||||||
|
#end
|
||||||
|
#end
|
||||||
|
#if(withSwagger && swaggerVersion.getName() == "FOX")
|
||||||
|
@ApiModel("#(table.getComment())")
|
||||||
|
#end
|
||||||
|
#if(withSwagger && swaggerVersion.getName() == "DOC")
|
||||||
|
@Schema(description = "#(table.getComment())")
|
||||||
|
#end
|
||||||
|
public class #(entityClassName)Vo#if(withActiveRecord) extends Model<#(entityClassName)>#else#(table.buildImplements())#end {
|
||||||
|
|
||||||
|
#for(column : table.columns)
|
||||||
|
#set(comment = javadocConfig.formatColumnComment(column.comment))
|
||||||
|
#if(isNotBlank(comment))
|
||||||
|
/**
|
||||||
|
* #(comment)
|
||||||
|
*/
|
||||||
|
#end
|
||||||
|
#if(isNotBlank(annotations))
|
||||||
|
#(annotations)
|
||||||
|
#end
|
||||||
|
#if(withSwagger && swaggerVersion.getName() == "FOX")
|
||||||
|
@ApiModelProperty("#(column.comment)")
|
||||||
|
#end
|
||||||
|
#if(withSwagger && swaggerVersion.getName() == "DOC")
|
||||||
|
@Schema(description = "#(column.comment)")
|
||||||
|
#end
|
||||||
|
private #(column.propertySimpleType) #(column.property)#if(isNotBlank(column.propertyDefaultValue)) = #(column.propertyDefaultValue)#end;
|
||||||
|
|
||||||
|
#end
|
||||||
|
#if(!withLombok)
|
||||||
|
#if(withActiveRecord)
|
||||||
|
public static #(entityClassName) create() {
|
||||||
|
return new #(entityClassName)();
|
||||||
|
}
|
||||||
|
|
||||||
|
#end
|
||||||
|
#for(column: table.columns)
|
||||||
|
public #(column.propertySimpleType) #(column.getterMethod())() {
|
||||||
|
return #(column.property);
|
||||||
|
}
|
||||||
|
|
||||||
|
#if(withActiveRecord)
|
||||||
|
public #(entityClassName) #(column.setterMethod())(#(column.propertySimpleType) #(column.property)) {
|
||||||
|
this.#(column.property) = #(column.property);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
public void #(column.setterMethod())(#(column.propertySimpleType) #(column.property)) {
|
||||||
|
this.#(column.property) = #(column.property);
|
||||||
|
}
|
||||||
|
#end
|
||||||
|
|
||||||
|
#end
|
||||||
|
#end}
|
||||||
13
pom.xml
13
pom.xml
@ -32,6 +32,7 @@
|
|||||||
<easyexcel.version>3.3.2</easyexcel.version>
|
<easyexcel.version>3.3.2</easyexcel.version>
|
||||||
<commons-compress.version>1.21</commons-compress.version>
|
<commons-compress.version>1.21</commons-compress.version>
|
||||||
<jjwt.version>0.9.1</jjwt.version>
|
<jjwt.version>0.9.1</jjwt.version>
|
||||||
|
<HikariCP.version>4.0.3</HikariCP.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<dependencyManagement>
|
<dependencyManagement>
|
||||||
@ -78,6 +79,12 @@
|
|||||||
<artifactId>Cpop-Core</artifactId>
|
<artifactId>Cpop-Core</artifactId>
|
||||||
<version>${cpop.version}</version>
|
<version>${cpop.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<!--HikariCP-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.zaxxer</groupId>
|
||||||
|
<artifactId>HikariCP</artifactId>
|
||||||
|
<version>${HikariCP.version}</version>
|
||||||
|
</dependency>
|
||||||
<!--Mybatis-flex-->
|
<!--Mybatis-flex-->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.mybatis-flex</groupId>
|
<groupId>com.mybatis-flex</groupId>
|
||||||
@ -89,6 +96,12 @@
|
|||||||
<artifactId>mybatis-flex-processor</artifactId>
|
<artifactId>mybatis-flex-processor</artifactId>
|
||||||
<version>${mybatis-flex.version}</version>
|
<version>${mybatis-flex.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<!--代码生成器-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.mybatis-flex</groupId>
|
||||||
|
<artifactId>mybatis-flex-codegen</artifactId>
|
||||||
|
<version>${mybatis-flex.version}</version>
|
||||||
|
</dependency>
|
||||||
<!--easyExcel-->
|
<!--easyExcel-->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.alibaba</groupId>
|
<groupId>com.alibaba</groupId>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user