package ${package.Entity}; <#list table.importPackages as pkg> 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; import com.fasterxml.jackson.annotation.JsonProperty; <#if cfg.boEntList?exists> <#if cfg.cgUtil.getSubModelInfo(cfg.boEntList,table.name)?? && (cfg.cgUtil.getSubModelInfo(cfg.boEntList,table.name)?size>0) > import java.util.List; /** * ${table.comment!} * <#if cfg.companyName??> * @company ${cfg.companyName} * @author ${author} <#if cfg.authorEmail??> * @email ${cfg.authorEmail} * @since ${date} */ <#if entityLombokModel> @Data <#if 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 superEntityClass??> public class ${entity} extends ${superEntityClass}<#if activeRecord><${entity}> { <#elseif activeRecord> public class ${entity} extends Model<${entity}> { <#else> public class ${entity} implements Serializable { <#if entitySerialVersionUID> private static final long serialVersionUID = 1L; <#-- ---------- BEGIN 字段循环遍历 ----------> <#list table.fields as field> <#if field.keyFlag> <#assign keyPropertyName="${field.propertyName}"/> <#assign propertyName>${cfg.cgUtil.getPropertyName(cfg.boEntList,table.name,field.name,field.propertyName)} <#if propertyName == "tenantId"> <#continue> <#if field.comment!?length gt 0> <#if swagger2> @ApiModelProperty(value = "${field.comment}") <#else> /** * ${field.comment} */ <#if field.keyFlag> <#-- 主键 --> <#if field.keyIdentityFlag> @TableId(value = "${field.name}", type = IdType.AUTO) <#elseif idType??> @TableId(value = "${field.name}", type = IdType.${idType}) <#elseif field.convert> @TableId("${field.name}") <#-- 普通字段 --> <#elseif field.fill??> <#-- ----- 存在字段填充设置 -----> <#if field.convert> @TableField(value = "${field.name}", fill = FieldFill.${field.fill}) <#else> @TableField(fill = FieldFill.${field.fill}) <#else> @TableField("${field.name}") <#-- 乐观锁注解 --> <#if (versionFieldName!"") == field.name> @Version <#-- 逻辑删除注解 --> <#if (logicDeleteFieldName!"") == field.name> @TableLogic @JsonProperty("${propertyName}") private ${field.propertyType} ${propertyName}; <#------------ END 字段循环遍历 ----------> <#------------ 子表属性 ----------> <#if cfg.boEntList?exists> <#list cfg.cgUtil.getSubModelInfo(cfg.boEntList,table.name) as subModel> @ApiModelProperty(value = "${subModel.comment}") @TableField(exist = false) private List<${subModel.className}> ${subModel.propertyName}; <#------------ END 子表属性 ----------> <#if !entityLombokModel> <#list table.fields as field> <#if field.propertyType == "boolean"> <#assign getprefix="is"/> <#else> <#assign getprefix="get"/> <#assign propertyName>${cfg.cgUtil.getPropertyName(cfg.boEntList,table.name,field.name,field.propertyName)} <#if propertyName == "tenantId"> <#continue> public ${field.propertyType} ${getprefix}${propertyName?cap_first}() { return ${propertyName}; } <#if entityBuilderModel> public ${entity} set${propertyName?cap_first}(${field.propertyType} ${propertyName}) { <#else> public void set${propertyName?cap_first}(${field.propertyType} ${propertyName}) { this.${propertyName} = ${propertyName}; <#if entityBuilderModel> return this; } <#------------ 子表get/set方法 ----------> <#if cfg.boEntList?exists> <#list cfg.cgUtil.getSubModelInfo(cfg.boEntList,table.name) as subModel> /** * get ${subModel.comment}数据 * @return */ public List<${subModel.className}> get${subModel.propertyName?cap_first}(){ return this.${subModel.propertyName}; } /** * set ${subModel.comment}数据 * @param ${subModel.propertyName} */ public void set${subModel.propertyName?cap_first}(List<${subModel.className}> ${subModel.propertyName}){ this.${subModel.propertyName} = ${subModel.propertyName}; } <#------------ END 子表get/set方法 ----------> <#if entityColumnConstant> <#list table.fields as field> public static final String ${field.name?upper_case} = "${field.name}"; <#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> <#assign propertyName>${cfg.cgUtil.getPropertyName(cfg.boEntList,table.name,field.name,field.propertyName)} <#if propertyName == "tenantId"> <#continue> <#if field_index==0> "${propertyName}=" + ${propertyName} + <#else> ", ${propertyName}=" + ${propertyName} + "}"; } }