|
@@ -0,0 +1,160 @@
|
|
|
+package ${package.Entity};
|
|
|
+<% for(pkg in table.importPackages){ %>
|
|
|
+import ${pkg};
|
|
|
+<% } %>
|
|
|
+<% if(swagger2){ %>
|
|
|
+import io.swagger.annotations.ApiModel;
|
|
|
+import io.swagger.annotations.ApiModelProperty;
|
|
|
+<% } %>
|
|
|
+<% if(entityLombokModel){ %>
|
|
|
+import lombok.Data;
|
|
|
+import lombok.EqualsAndHashCode;
|
|
|
+import lombok.experimental.Accessors;
|
|
|
+<% } %>
|
|
|
+/**
|
|
|
+ * <p>
|
|
|
+ * ${table.comment!}
|
|
|
+ * </p>
|
|
|
+ *
|
|
|
+ * @author ${author}
|
|
|
+ * @since ${date}
|
|
|
+ */
|
|
|
+<% if(entityLombokModel){ %>
|
|
|
+@Data
|
|
|
+ <% if(isNotEmpty(superEntityClass)){ %>
|
|
|
+@EqualsAndHashCode(callSuper = true)
|
|
|
+ <% }else{ %>
|
|
|
+@EqualsAndHashCode(callSuper = false)
|
|
|
+ <% } %>
|
|
|
+@Accessors(chain = true)
|
|
|
+<% } %>
|
|
|
+<% if(table.convert){ %>
|
|
|
+@TableName("${table.name}")
|
|
|
+<% } %>
|
|
|
+<% if(swagger2){ %>
|
|
|
+@ApiModel(value="${entity}对象", description="${table.comment!''}")
|
|
|
+<% } %>
|
|
|
+<% if(isNotEmpty(superEntityClass)){ %>
|
|
|
+public class ${entity} extends ${superEntityClass}<% if(activeRecord){ %><${entity}><%}%>{
|
|
|
+<% }else if(activeRecord){ %>
|
|
|
+public class ${entity} extends Model<${entity}> {
|
|
|
+<% }else{ %>
|
|
|
+public class ${entity} implements Serializable {
|
|
|
+<% } %>
|
|
|
+
|
|
|
+ private static final long serialVersionUID = 1L;
|
|
|
+<% /** -----------BEGIN 字段循环遍历----------- **/ %>
|
|
|
+<% for(field in table.fields){ %>
|
|
|
+ <%
|
|
|
+ if(field.keyFlag){
|
|
|
+ var keyPropertyName = field.propertyName;
|
|
|
+ }
|
|
|
+ %>
|
|
|
+
|
|
|
+ <% if(isNotEmpty(field.comment)){ %>
|
|
|
+ <% if(swagger2){ %>
|
|
|
+ @ApiModelProperty(value = "${field.comment}")
|
|
|
+ <% }else{ %>
|
|
|
+ /**
|
|
|
+ * ${field.comment}
|
|
|
+ */
|
|
|
+ <% } %>
|
|
|
+ <% } %>
|
|
|
+ <% if(field.keyFlag){ %>
|
|
|
+ <%
|
|
|
+ /*主键*/
|
|
|
+ %>
|
|
|
+ <% if(field.keyIdentityFlag){ %>
|
|
|
+ @TableId(value = "${field.name}", type = IdType.AUTO)
|
|
|
+ <% }else if(isNotEmpty(idType)){ %>
|
|
|
+ @TableId(value = "${field.name}", type = IdType.${idType})
|
|
|
+ <% }else if(field.convert){ %>
|
|
|
+ @TableId("${field.name}")
|
|
|
+ <% } %>
|
|
|
+ <%
|
|
|
+ /*普通字段*/
|
|
|
+ %>
|
|
|
+ <% }else if(isNotEmpty(field.fill)){ %>
|
|
|
+ <% if(field.convert){ %>
|
|
|
+ @TableField(value = "${field.name}", fill = FieldFill.${field.fill})
|
|
|
+ <% }else{ %>
|
|
|
+ @TableField(fill = FieldFill.${field.fill})
|
|
|
+ <% } %>
|
|
|
+ <% }else if(field.convert){ %>
|
|
|
+ @TableField("${field.name}")
|
|
|
+ <% } %>
|
|
|
+ <%
|
|
|
+ /*乐观锁注解*/
|
|
|
+ %>
|
|
|
+ <% if(versionFieldName!'' == field.name){ %>
|
|
|
+ @Version
|
|
|
+ <% } %>
|
|
|
+ <%
|
|
|
+ /*逻辑删除注解*/
|
|
|
+ %>
|
|
|
+ <% if(logicDeleteFieldName!'' == field.name){ %>
|
|
|
+ @Version
|
|
|
+ <% } %>
|
|
|
+ private ${field.propertyType} ${field.propertyName};
|
|
|
+<% } %>
|
|
|
+<% /** -----------END 字段循环遍历----------- **/ %>
|
|
|
+
|
|
|
+<% if(!entityLombokModel){ %>
|
|
|
+ <% for(field in table.fields){ %>
|
|
|
+ <%
|
|
|
+ var getprefix ='';
|
|
|
+ if(field.propertyType=='boolean'){
|
|
|
+ getprefix='is';
|
|
|
+ }else{
|
|
|
+ getprefix='get';
|
|
|
+ }
|
|
|
+ %>
|
|
|
+ public ${field.propertyType} ${getprefix}${field.capitalName}() {
|
|
|
+ return ${field.propertyName};
|
|
|
+ }
|
|
|
+
|
|
|
+ <% if(entityBuilderModel){ %>
|
|
|
+ public ${entity} set${field.capitalName}(${field.propertyType} ${field.propertyName}) {
|
|
|
+ <% }else{ %>
|
|
|
+ public void set${field.capitalName}(${field.propertyType} ${field.propertyName}) {
|
|
|
+ <% } %>
|
|
|
+ this.${field.propertyName} = ${field.propertyName};
|
|
|
+ <% if(entityBuilderModel){ %>
|
|
|
+ return this;
|
|
|
+ <% } %>
|
|
|
+ }
|
|
|
+
|
|
|
+ <% } %>
|
|
|
+<% } %>
|
|
|
+<% if(entityColumnConstant){ %>
|
|
|
+ <% for(field in table.fields){ %>
|
|
|
+ public static final String ${strutil.toUpperCase(field.name)} = "${field.name}";
|
|
|
+
|
|
|
+ <% } %>
|
|
|
+<% } %>
|
|
|
+<% if(activeRecord){ %>
|
|
|
+ @Override
|
|
|
+ protected Serializable pkVal() {
|
|
|
+ <% if(isNotEmpty(keyPropertyName)){ %>
|
|
|
+ return this.${keyPropertyName};
|
|
|
+ <% }else{ %>
|
|
|
+ return null;
|
|
|
+ <% } %>
|
|
|
+ }
|
|
|
+
|
|
|
+<% } %>
|
|
|
+<% if(!entityLombokModel){ %>
|
|
|
+ @Override
|
|
|
+ public String toString() {
|
|
|
+ return "${entity}{" +
|
|
|
+ <% for(field in table.fields){ %>
|
|
|
+ <% if(fieldLP.index==0){ %>
|
|
|
+ "${field.propertyName}=" + ${field.propertyName} +
|
|
|
+ <% }else{ %>
|
|
|
+ ", ${field.propertyName}=" + ${field.propertyName} +
|
|
|
+ <% } %>
|
|
|
+ <% } %>
|
|
|
+ "}";
|
|
|
+ }
|
|
|
+<% } %>
|
|
|
+}
|