mirror of
https://gitee.com/mybatis-flex/mybatis-flex.git
synced 2025-12-07 09:08:24 +08:00
feat: 提取 lombok 配置到模板。
This commit is contained in:
parent
6e08986d39
commit
e4a042d760
@ -128,18 +128,6 @@ public class Table {
|
|||||||
|
|
||||||
EntityConfig entityConfig = globalConfig.getEntityConfig();
|
EntityConfig entityConfig = globalConfig.getEntityConfig();
|
||||||
|
|
||||||
//开启 lombok
|
|
||||||
if (entityConfig.isWithLombok()) {
|
|
||||||
//import lombok.AllArgsConstructor;
|
|
||||||
//import lombok.Builder;
|
|
||||||
//import lombok.Data;
|
|
||||||
//import lombok.NoArgsConstructor;
|
|
||||||
imports.add("lombok.AllArgsConstructor");
|
|
||||||
imports.add("lombok.Builder");
|
|
||||||
imports.add("lombok.Data");
|
|
||||||
imports.add("lombok.NoArgsConstructor");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (entityConfig.getSupperClass() != null) {
|
if (entityConfig.getSupperClass() != null) {
|
||||||
imports.add(entityConfig.getSupperClass().getName());
|
imports.add(entityConfig.getSupperClass().getName());
|
||||||
}
|
}
|
||||||
@ -277,16 +265,6 @@ public class Table {
|
|||||||
*/
|
*/
|
||||||
public String buildTableAnnotation() {
|
public String buildTableAnnotation() {
|
||||||
StringBuilder tableAnnotation = new StringBuilder();
|
StringBuilder tableAnnotation = new StringBuilder();
|
||||||
if (globalConfig.getEntityConfig().isWithLombok()) {
|
|
||||||
//@Data
|
|
||||||
//@Builder
|
|
||||||
//@NoArgsConstructor
|
|
||||||
//@AllArgsConstructor
|
|
||||||
tableAnnotation.append("@Data\n");
|
|
||||||
tableAnnotation.append("@Builder\n");
|
|
||||||
tableAnnotation.append("@NoArgsConstructor\n");
|
|
||||||
tableAnnotation.append("@AllArgsConstructor\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
tableAnnotation.append("@Table(value = \"").append(name).append("\"");
|
tableAnnotation.append("@Table(value = \"").append(name).append("\"");
|
||||||
|
|
||||||
|
|||||||
@ -1,8 +1,15 @@
|
|||||||
|
#set(withLombok = entityConfig.isWithLombok())
|
||||||
package #(packageConfig.entityPackage);
|
package #(packageConfig.entityPackage);
|
||||||
|
|
||||||
#for(importClass : table.buildImports())
|
#for(importClass : table.buildImports())
|
||||||
import #(importClass);
|
import #(importClass);
|
||||||
#end
|
#end
|
||||||
|
#if(withLombok)
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
#end
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* #(table.getComment()) 实体类。
|
* #(table.getComment()) 实体类。
|
||||||
@ -10,6 +17,12 @@ import #(importClass);
|
|||||||
* @author #(javadocConfig.getAuthor())
|
* @author #(javadocConfig.getAuthor())
|
||||||
* @since #(javadocConfig.getSince())
|
* @since #(javadocConfig.getSince())
|
||||||
*/
|
*/
|
||||||
|
#if(withLombok)
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
#end
|
||||||
#(table.buildTableAnnotation())
|
#(table.buildTableAnnotation())
|
||||||
public class #(table.buildEntityClassName())#(table.buildExtends())#(table.buildImplements()) {
|
public class #(table.buildEntityClassName())#(table.buildExtends())#(table.buildImplements()) {
|
||||||
#for(column : table.columns)
|
#for(column : table.columns)
|
||||||
@ -18,7 +31,7 @@ public class #(table.buildEntityClassName())#(table.buildExtends())#(table.build
|
|||||||
#(column.buildAnnotations())private #(column.propertySimpleType) #(column.property);
|
#(column.buildAnnotations())private #(column.propertySimpleType) #(column.property);
|
||||||
#end
|
#end
|
||||||
|
|
||||||
#if(!entityConfig.isWithLombok())
|
#if(!withLombok)
|
||||||
#for(column: table.columns)
|
#for(column: table.columns)
|
||||||
public #(column.propertySimpleType) #(column.getterMethod())() {
|
public #(column.propertySimpleType) #(column.getterMethod())() {
|
||||||
return #(column.property);
|
return #(column.property);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user