mirror of
https://gitee.com/mybatis-flex/mybatis-flex.git
synced 2025-12-06 16:48:24 +08:00
feature:代码生成器添加配置 entity 前后缀配置的功能
This commit is contained in:
parent
58dd10a9ce
commit
46376023c5
@ -91,13 +91,19 @@ GlobalConfig 支持更多的配置如下:
|
||||
```java
|
||||
|
||||
public class GlobalConfig {
|
||||
|
||||
|
||||
//代码生成目录
|
||||
private String sourceDir;
|
||||
|
||||
//entity 的包名
|
||||
private String entityPackage;
|
||||
|
||||
//mapper 类的前缀
|
||||
private String entityClassPrefix = "";
|
||||
|
||||
//mapper 类的后缀
|
||||
private String entityClassSuffix = "";
|
||||
|
||||
//entity 是否使用 Lombok
|
||||
private boolean entityWithLombok = false;
|
||||
|
||||
|
||||
@ -63,7 +63,8 @@ public class Generator {
|
||||
for (Table table : tables) {
|
||||
|
||||
String entityPackagePath = globalConfig.getEntityPackage().replace(".", "/");
|
||||
File entityJavaFile = new File(globalConfig.getSourceDir(), entityPackagePath + "/" + table.buildEntityClassName() + ".java");
|
||||
File entityJavaFile = new File(globalConfig.getSourceDir(), entityPackagePath + "/" +
|
||||
globalConfig.getEntityClassPrefix() + table.buildEntityClassName() + globalConfig.getEntityClassSuffix() + ".java");
|
||||
if (!entityJavaFile.getParentFile().exists()) {
|
||||
if (!entityJavaFile.getParentFile().mkdirs()) {
|
||||
throw new IllegalStateException("Can not mkdirs by dir: " + entityJavaFile.getParentFile());
|
||||
|
||||
@ -32,6 +32,12 @@ public class GlobalConfig {
|
||||
//entity 的包名
|
||||
private String entityPackage;
|
||||
|
||||
//mapper 类的前缀
|
||||
private String entityClassPrefix = "";
|
||||
|
||||
//mapper 类的后缀
|
||||
private String entityClassSuffix = "";
|
||||
|
||||
//entity 是否使用 Lombok
|
||||
private boolean entityWithLombok = false;
|
||||
|
||||
@ -100,6 +106,22 @@ public class GlobalConfig {
|
||||
this.entityPackage = entityPackage.trim();
|
||||
}
|
||||
|
||||
public String getEntityClassPrefix() {
|
||||
return entityClassPrefix;
|
||||
}
|
||||
|
||||
public void setEntityClassPrefix(String entityClassPrefix) {
|
||||
this.entityClassPrefix = entityClassPrefix;
|
||||
}
|
||||
|
||||
public String getEntityClassSuffix() {
|
||||
return entityClassSuffix;
|
||||
}
|
||||
|
||||
public void setEntityClassSuffix(String entityClassSuffix) {
|
||||
this.entityClassSuffix = entityClassSuffix;
|
||||
}
|
||||
|
||||
public boolean isEntityWithLombok() {
|
||||
return entityWithLombok;
|
||||
}
|
||||
|
||||
@ -6,7 +6,7 @@ import #(importClass);
|
||||
|
||||
|
||||
#(table.buildTableAnnotation())
|
||||
public class #(table.buildEntityClassName()) {
|
||||
public class #(globalConfig.entityClassPrefix ??)#(table.buildEntityClassName())#(globalConfig.entityClassSuffix ??) {
|
||||
|
||||
#for(column: table.columns) #(column.buildAnnotations())
|
||||
private #(column.propertySimpleType) #(column.property);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user