|
@@ -0,0 +1,150 @@
|
|
1
|
+package ${package.Entity};
|
|
2
|
+
|
|
3
|
+<#list table.importPackages as pkg>
|
|
4
|
+import ${pkg};
|
|
5
|
+</#list>
|
|
6
|
+<#if swagger2>
|
|
7
|
+import io.swagger.annotations.ApiModel;
|
|
8
|
+import io.swagger.annotations.ApiModelProperty;
|
|
9
|
+</#if>
|
|
10
|
+<#if entityLombokModel>
|
|
11
|
+import lombok.Data;
|
|
12
|
+import lombok.EqualsAndHashCode;
|
|
13
|
+import lombok.experimental.Accessors;
|
|
14
|
+</#if>
|
|
15
|
+
|
|
16
|
+/**
|
|
17
|
+ * <p>
|
|
18
|
+ * ${table.comment!}
|
|
19
|
+ * </p>
|
|
20
|
+ *
|
|
21
|
+ * @author ${author}
|
|
22
|
+ * @since ${date}
|
|
23
|
+ */
|
|
24
|
+<#if entityLombokModel>
|
|
25
|
+@Data
|
|
26
|
+ <#if superEntityClass??>
|
|
27
|
+@EqualsAndHashCode(callSuper = true)
|
|
28
|
+ <#else>
|
|
29
|
+@EqualsAndHashCode(callSuper = false)
|
|
30
|
+ </#if>
|
|
31
|
+@Accessors(chain = true)
|
|
32
|
+</#if>
|
|
33
|
+<#if table.convert>
|
|
34
|
+@TableName("${table.name}")
|
|
35
|
+</#if>
|
|
36
|
+<#if swagger2>
|
|
37
|
+@ApiModel(value="${entity}对象", description="${table.comment!}")
|
|
38
|
+</#if>
|
|
39
|
+<#if superEntityClass??>
|
|
40
|
+public class ${entity} extends ${superEntityClass}<#if activeRecord><${entity}></#if> {
|
|
41
|
+<#elseif activeRecord>
|
|
42
|
+public class ${entity} extends Model<${entity}> {
|
|
43
|
+<#else>
|
|
44
|
+public class ${entity} implements Serializable {
|
|
45
|
+</#if>
|
|
46
|
+
|
|
47
|
+ private static final long serialVersionUID = 1L;
|
|
48
|
+<#-- ---------- BEGIN 字段循环遍历 ---------->
|
|
49
|
+<#list table.fields as field>
|
|
50
|
+ <#if field.keyFlag>
|
|
51
|
+ <#assign keyPropertyName="${field.propertyName}"/>
|
|
52
|
+ </#if>
|
|
53
|
+
|
|
54
|
+ <#if field.comment!?length gt 0>
|
|
55
|
+ <#if swagger2>
|
|
56
|
+ @ApiModelProperty(value = "${field.comment}")
|
|
57
|
+ <#else>
|
|
58
|
+ /**
|
|
59
|
+ * ${field.comment}
|
|
60
|
+ */
|
|
61
|
+ </#if>
|
|
62
|
+ </#if>
|
|
63
|
+ <#if field.keyFlag>
|
|
64
|
+ <#-- 主键 -->
|
|
65
|
+ <#if field.keyIdentityFlag>
|
|
66
|
+ @TableId(value = "${field.name}", type = IdType.AUTO)
|
|
67
|
+ <#elseif idType??>
|
|
68
|
+ @TableId(value = "${field.name}", type = IdType.${idType})
|
|
69
|
+ <#elseif field.convert>
|
|
70
|
+ @TableId("${field.name}")
|
|
71
|
+ </#if>
|
|
72
|
+ <#-- 普通字段 -->
|
|
73
|
+ <#elseif field.fill??>
|
|
74
|
+ <#-- ----- 存在字段填充设置 ----->
|
|
75
|
+ <#if field.convert>
|
|
76
|
+ @TableField(value = "${field.name}", fill = FieldFill.${field.fill})
|
|
77
|
+ <#else>
|
|
78
|
+ @TableField(fill = FieldFill.${field.fill})
|
|
79
|
+ </#if>
|
|
80
|
+ <#elseif field.convert>
|
|
81
|
+ @TableField("${field.name}")
|
|
82
|
+ </#if>
|
|
83
|
+<#-- 乐观锁注解 -->
|
|
84
|
+ <#if (versionFieldName!"") == field.name>
|
|
85
|
+ @Version
|
|
86
|
+ </#if>
|
|
87
|
+<#-- 逻辑删除注解 -->
|
|
88
|
+ <#if (logicDeleteFieldName!"") == field.name>
|
|
89
|
+ @TableLogic
|
|
90
|
+ </#if>
|
|
91
|
+ private ${field.propertyType} ${field.propertyName};
|
|
92
|
+</#list>
|
|
93
|
+<#------------ END 字段循环遍历 ---------->
|
|
94
|
+
|
|
95
|
+<#if !entityLombokModel>
|
|
96
|
+ <#list table.fields as field>
|
|
97
|
+ <#if field.propertyType == "boolean">
|
|
98
|
+ <#assign getprefix="is"/>
|
|
99
|
+ <#else>
|
|
100
|
+ <#assign getprefix="get"/>
|
|
101
|
+ </#if>
|
|
102
|
+ public ${field.propertyType} ${getprefix}${field.capitalName}() {
|
|
103
|
+ return ${field.propertyName};
|
|
104
|
+ }
|
|
105
|
+
|
|
106
|
+ <#if entityBuilderModel>
|
|
107
|
+ public ${entity} set${field.capitalName}(${field.propertyType} ${field.propertyName}) {
|
|
108
|
+ <#else>
|
|
109
|
+ public void set${field.capitalName}(${field.propertyType} ${field.propertyName}) {
|
|
110
|
+ </#if>
|
|
111
|
+ this.${field.propertyName} = ${field.propertyName};
|
|
112
|
+ <#if entityBuilderModel>
|
|
113
|
+ return this;
|
|
114
|
+ </#if>
|
|
115
|
+ }
|
|
116
|
+ </#list>
|
|
117
|
+</#if>
|
|
118
|
+
|
|
119
|
+<#if entityColumnConstant>
|
|
120
|
+ <#list table.fields as field>
|
|
121
|
+ public static final String ${field.name?upper_case} = "${field.name}";
|
|
122
|
+
|
|
123
|
+ </#list>
|
|
124
|
+</#if>
|
|
125
|
+<#if activeRecord>
|
|
126
|
+ @Override
|
|
127
|
+ protected Serializable pkVal() {
|
|
128
|
+ <#if keyPropertyName??>
|
|
129
|
+ return this.${keyPropertyName};
|
|
130
|
+ <#else>
|
|
131
|
+ return null;
|
|
132
|
+ </#if>
|
|
133
|
+ }
|
|
134
|
+
|
|
135
|
+</#if>
|
|
136
|
+<#if !entityLombokModel>
|
|
137
|
+ @Override
|
|
138
|
+ public String toString() {
|
|
139
|
+ return "${entity}{" +
|
|
140
|
+ <#list table.fields as field>
|
|
141
|
+ <#if field_index==0>
|
|
142
|
+ "${field.propertyName}=" + ${field.propertyName} +
|
|
143
|
+ <#else>
|
|
144
|
+ ", ${field.propertyName}=" + ${field.propertyName} +
|
|
145
|
+ </#if>
|
|
146
|
+ </#list>
|
|
147
|
+ "}";
|
|
148
|
+ }
|
|
149
|
+</#if>
|
|
150
|
+}
|