package ${package.Entity}; <#list table.importPackages as pkg> import ${pkg}; <#if swagger2> import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import javax.validation.constraints.NotEmpty; import javax.validation.constraints.NotNull; import javax.validation.constraints.Size; import java.time.LocalDateTime; import java.util.HashMap; import java.util.Map; <#if entityLombokModel> import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.NoArgsConstructor; import lombok.ToString; import lombok.experimental.Accessors; <#if cfg.filedTypes??> <#list cfg.filedTypes as fieldType> <#list table.fields as field> <#if field.propertyName == fieldType.name && table.name==fieldType.table && field.propertyType=="String"> import ${fieldType.packagePath}; <#break> import static com.baomidou.mybatisplus.annotation.SqlCondition.LIKE; <#assign tableComment = "${table.comment!''}"/> <#if table.comment?? && table.comment!?contains('\n')> <#assign tableComment = "${table.comment!?substring(0,table.comment?index_of('\n'))?trim}"/> /** *

* 实体类 * ${table.comment!?replace("\n","\n * ")} *

* * @author ${author} * @since ${date} */ <#if entityLombokModel> @Data @NoArgsConstructor @ToString(callSuper = true) <#if superEntityClass??> @EqualsAndHashCode(callSuper = true) <#else> @EqualsAndHashCode(callSuper = false) @Accessors(chain = true) <#if table.convert> @TableName("${table.name}") <#if swagger2> @ApiModel(value = "${entity}", description = "${tableComment}") <#if superEntityClass??> @AllArgsConstructor <#assign hasCustomAnno="0"/> <#if superEntityClass?? && superEntityClass=="TreeEntity"> <#assign hasCustomAnno="1"/> public class ${entity} extends Entity { <#elseif activeRecord> @AllArgsConstructor public class ${entity} extends Entity { <#else> public class ${entity} extends Entity { private static final long serialVersionUID = 1L; @TableField(exist = false) private Map echoMap = new HashMap<>(); <#setting number_format="0"> <#-- ---------- BEGIN 字段循环遍历 ----------> <#list table.fields as field> <#-- 如果有父类,排除公共字段 --> <#if (superEntityClass?? && cfg.superExtend?? && field.propertyName !="id") || (superEntityClass?? && field.propertyName !="id" && field.propertyName !="createTime" && field.propertyName != "updateTime" && field.propertyName !="createUser" && field.propertyName !="updateUser") || !superEntityClass??> <#if field.keyFlag> <#assign keyPropertyName="${field.propertyName}"/> <#assign fieldComment="${field.comment!}"/> <#if field.comment!?length gt 0> /** * ${field.comment!?replace("\n","\n * ")} */ <#if field.comment!?contains("\n") > <#assign fieldComment="${field.comment!?substring(0,field.comment?index_of('\n'))?replace('\r\n','')?replace('\r','')?replace('\n','')?trim}"/> <#if swagger2> @ApiModelProperty(value = "${fieldComment}") <#assign myPropertyType="${field.propertyType}"/> <#assign isEnumType="1"/> <#list cfg.filedTypes as fieldType> <#if fieldType.name == field.propertyName && table.name==fieldType.table && field.propertyType=="String"> <#assign myPropertyType="${fieldType.type}"/> <#assign isEnumType="2"/> <#if field.customMap.Null == "NO" > <#if (field.columnType!"") == "STRING" && isEnumType == "1"> @NotEmpty(message = "请填写${fieldComment}") <#else> @NotNull(message = "请填写${fieldComment}") <#if (field.columnType!"") == "STRING" && isEnumType == "1"> <#assign max = 255/> <#if field.type?starts_with("varchar") || field.type?starts_with("char")> <#if field.type?contains("(")> <#assign max = field.type?substring(field.type?index_of("(") + 1, field.type?index_of(")"))/> @Size(max = ${max}, message = "${fieldComment}长度不能超过${max}") <#elseif field.type?starts_with("text")> <#assign max = 65535/> @Size(max = ${max}, message = "${fieldComment}长度不能超过${max}") <#elseif field.type?starts_with("mediumtext")> <#assign max = 16777215/> @Size(max = ${max}, message = "${fieldComment}长度不能超过${max}") <#elseif field.type?starts_with("longtext")> <#else> <#if field.propertyType?starts_with("Short")> @Size(min = Short.MIN_VALUE, max = Short.MAX_VALUE, message = "${fieldComment}长度不能超过"+Short.MAX_VALUE) <#if field.propertyType?starts_with("Byte")> @Size(min = Byte.MIN_VALUE, max = Byte.MAX_VALUE, message = "${fieldComment}长度不能超过"+Byte.MAX_VALUE) <#if field.propertyType?starts_with("Short")> @Size(min = Short.MIN_VALUE, max = Short.MAX_VALUE, message = "${fieldComment}长度不能超过"+Short.MAX_VALUE) <#if field.keyFlag> <#-- 主键 --> @TableId(value = "${field.name}"<#if field.keyIdentityFlag>, type = IdType.AUTO<#elseif idType??>, type = IdType.${idType}) <#else> @TableField(value = "${field.name}"<#if field.fill??>, fill = FieldFill.${field.fill}<#if myPropertyType == "String">, condition = LIKE<#else>) <#-- 乐观锁注解 --> <#if (versionFieldName!"") == field.name> @Version <#-- 逻辑删除注解 --> <#if (logicDeleteFieldName!"") == field.name> @TableLogic <#assign myPropertyName="${field.propertyName}"/> <#-- 自动注入注解 --> <#if field.customMap.annotation??> ${field.customMap.annotation} <#-- <#assign myPropertyType="${field.customMap.type}"/>--> <#-- <#if field.propertyName?ends_with("Id")>--> <#-- <#assign myPropertyName="${field.propertyName!?substring(0,field.propertyName?index_of('Id'))}"/>--> <#-- --> @Excel(name = "${fieldComment}"<#if myPropertyType!?contains("Local")>, format = "yyyy-MM-dd", width = 20<#if myPropertyType!?contains("Boolean")>, replace = {"是_true", "否_false", "_null"}<#if isEnumType=="2">, replace = {<#list field.customMap.enumCustom.list?keys as key>"${field.customMap.enumCustom.list[key][0]}_${key?upper_case}", "_null"}) private ${myPropertyType} ${myPropertyName}; <#------------ END 字段循环遍历 ----------> <#if !entityLombokModel> <#list table.fields as field> <#if field.propertyType == "boolean"> <#assign getprefix="is"/> <#else> <#assign 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; } <#-- 如果有父类,自定义无全参构造方法 --> @Builder public ${entity}(<#list table.commonFields as cf><#if cf.propertyName!="tenantCode">${cf.propertyType} ${cf.propertyName}, <#list table.fields as field><#assign myPropertyType="${field.propertyType}"/><#list cfg.filedTypes as fieldType><#if fieldType.name == field.propertyName && table.name==fieldType.table && field.propertyType=="String"><#assign myPropertyType="${fieldType.type}"/><#if field_has_next>${((field_index + 1) % 6 ==0)?string('\r\n ', '')}${myPropertyType} ${field.propertyName}, <#else>${myPropertyType} ${field.propertyName}) { <#list table.commonFields as cf> <#if cf.propertyName!="tenantCode"> this.${cf.propertyName} = ${cf.propertyName}; <#list table.fields as field> <#assign myPropertyName="${field.propertyName}"/> <#-- 自动注入注解 --> <#-- <#if field.customMap.annotation?? && field.propertyName?ends_with("Id")>--> <#-- <#assign myPropertyName="${field.propertyName!?substring(0,field.propertyName?index_of('Id'))}"/>--> <#-- --> this.${myPropertyName} = ${field.propertyName}; } <#if activeRecord> @Override protected Serializable pkVal() { <#if keyPropertyName??> return this.${keyPropertyName}; <#else> return null; } <#if !entityLombokModel> @Override public String toString() { return "${entity}{" + <#list table.fields as field> <#if field_index==0> "${field.propertyName}=" + ${field.propertyName} + <#else> ", ${field.propertyName}=" + ${field.propertyName} + "}"; } }