package ${packageName}.model;
<#if table.tplCategory=="crud" >
    <#--判断主键类型，设置继承实体类 -->
    <#if pkColumn??&&pkColumn.javaType=="String" >
        <#assign Entity = "BaseEntityStr">
    <#elseif pkColumn??&&pkColumn.javaType=="Integer">
        <#assign Entity = "BaseEntityInt">
    <#elseif pkColumn??&&pkColumn.javaType=="Long">
        <#assign Entity = "BaseEntityLong">
    <#else>
        <#assign Entity = "BaseEntityLong">
    </#if>

<#elseif table.tplCategory=="sub" ||table.tplCategory=="subone">
    <#--判断主键类型，设置继承实体类 -->
    <#if pkColumn??&&pkColumn.javaType=="String" >
        <#assign Entity = "BaseEntityStr">
    <#elseif pkColumn??&&pkColumn.javaType=="Integer">
        <#assign Entity = "BaseEntityInt">
    <#elseif pkColumn??&&pkColumn.javaType=="Long">
        <#assign Entity = "BaseEntityLong">
    <#else>
        <#assign Entity = "BaseEntityLong">
    </#if>
<#else>
    <#assign Entity = "BaseEntityLong">
</#if>
<#list importList as import>
import ${import};
</#list>
<#list columns as column>
    <#if column.isSerialize==1>
import com.fasterxml.jackson.annotation.JsonProperty;
     <#break>
    </#if>
</#list>
import java.util.List;
import java.util.ArrayList;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.mortals.framework.annotation.Excel;
import com.mortals.framework.model.${Entity};
import ${packageName}.model.vo.${ClassName}Vo;
<#if table.tplCategory=="sub" ||table.tplCategory=="subone">
import ${subPackageName}.model.${subClassName}Entity;
</#if>
/**
* ${functionName}实体对象
*
* @author ${author}
* @date ${datetime}
*/

public class ${ClassName}Entity extends ${ClassName}Vo {
    private static final long serialVersionUID = 1L;

<#list columns as column>
<#if !column.isSuperColumn(column.javaField)>
    /** ${column.columnComment} */
    <#if column.isExport==1>
        <#assign comment=column.subComment(column.columnComment) />
        <#assign parentheseIndex =column.columnComment?index_of("(")>
        <#if parentheseIndex != -1>
    @Excel(name = "${comment}", readConverterExp = "${column.readConverterExp()}")
        <#elseif column.javaType == "Date">
    @Excel(name = "${comment}", width = 30, dateFormat = "yyyy-MM-dd")
        <#else>
    @Excel(name = "${comment}")
        </#if>
    </#if>
    <#if column.isSerialize==1>
    @JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
    </#if>
    private ${column.javaType} ${column.javaField};
</#if>
</#list>

<#if table.subTable?? && table.tplCategory=="sub" >
    /** ${table.subTable.functionName}信息 */
    private List<${subClassName}Entity> ${subclassName}List=new ArrayList<>();;
</#if>

<#if table.subTable?? && table.tplCategory=="subone" >
    /** ${table.subTable.functionName}信息 */
    private ${subClassName}Entity ${subclassName}Entity=new ${subClassName}Entity();
</#if>
<#list columns as column>
<#if column.javaType == "Long"||column.javaType == "Integer"||column.javaType == "BigDecimal">
    /** 开始 ${column.columnComment} */
    private ${column.javaType} ${column.javaField}Start;

    /** 结束 ${column.columnComment} */
    private ${column.javaType} ${column.javaField}End;

    /** 增加 ${column.columnComment} */
    private ${column.javaType} ${column.javaField}Increment;

    /** ${column.columnComment}列表 */
    private List <${column.javaType}> ${column.javaField}List;

</#if>
<#if column.javaType == "String">
    /** ${column.columnComment} */
    private List<${column.javaType}> ${column.javaField}List;

</#if>
<#if column.javaType == "Date">
    /** 开始 ${column.columnComment} */
    private String ${column.javaField}Start;

    /** 结束 ${column.columnComment} */
    private String ${column.javaField}End;

</#if>
</#list>
    /** OR条件集合，列表项之间是OR，项内容之间是AND，如：(list[0].1 and list[0].2) or (list[1].3 and list[1].4) */
    private List<${ClassName}Entity> orConditionList;

    /** AND条件集合，列表项之间是AND，项内容之间是OR，如：(list[0].1 or list[0].2) and (list[1].3 or list[1].4) */
    private List<${ClassName}Entity> andConditionList;

    public ${ClassName}Entity(){}
<#--get set属性 -->
<#list columns as column>
    <#if !column.isSuperColumn(column.javaField)>
        <#if column.javaField[0..1]?matches("[A-Z]")>
            <#assign AttrName = column.javaField>
            <#else>
            <#assign AttrName = column.javaField?cap_first>
        </#if>
    /**
    * 获取 ${column.columnComment}
    * @return ${column.javaType}
    */
    public ${column.javaType} get${AttrName}(){
        return ${column.javaField};
    }
    /**
    * 设置 ${column.columnComment}
    * @param ${column.javaField}
    */
    public void set${AttrName}(${column.javaType} ${column.javaField}){
        this.${column.javaField} = ${column.javaField};
    }
    </#if>
</#list>

<#if subTable?? && table.tplCategory=="sub">
    public List<${subClassName}Entity> get${subClassName}List(){
      return ${subclassName}List;
    }

    public void set${subClassName}List(List<${subClassName}Entity> ${subclassName}List){
        this.${subclassName}List = ${subclassName}List;
    }
</#if>
<#if subTable?? && table.tplCategory=="subone">
    public ${subClassName}Entity get${subClassName}Entity(){
        return ${subclassName}Entity;
    }

    public void set${subClassName}Entity(${subClassName}Entity ${subclassName}Entity){
        this.${subclassName}Entity = ${subclassName}Entity;
    }
</#if>
<#list columns as column>
    <#if column.javaType == "Long"||column.javaType == "Integer"||column.javaType == "BigDecimal">
    /**
    * 获取 开始 ${column.columnComment}
    * @return ${column.javaField}Start
    */
    public ${column.javaType} get${column.javaField?cap_first}Start(){
        return this.${column.javaField}Start;
    }

    /**
    * 设置 开始 ${column.columnComment}
    * @param ${column.javaField}Start
    */
    public void set${column.javaField?cap_first}Start(${column.javaType} ${column.javaField}Start){
        this.${column.javaField}Start = ${column.javaField}Start;
    }

    /**
    * 获取 结束 ${column.columnComment}
    * @return $${column.javaField}End
    */
    public ${column.javaType} get${column.javaField?cap_first}End(){
        return this.${column.javaField}End;
    }

    /**
    * 设置 结束 ${column.columnComment}
    * @param ${column.javaField}End
    */
    public void set${column.javaField?cap_first}End(${column.javaType} ${column.javaField}End){
        this.${column.javaField}End = ${column.javaField}End;
    }

    /**
    * 获取 增加 ${column.columnComment}
    * @return ${column.javaField}Increment
    */
    public ${column.javaType} get${column.javaField?cap_first}Increment(){
        return this.${column.javaField}Increment;
    }

    /**
    * 设置 增加 ${column.columnComment}
    * @param ${column.javaField}Increment
    */
    public void set${column.javaField?cap_first}Increment(${column.javaType} ${column.javaField}Increment){
        this.${column.javaField}Increment = ${column.javaField}Increment;
    }

    /**
    * 获取 ${column.columnComment}
    * @return ${column.javaField}List
    */
    public List<${column.javaType}> get${column.javaField?cap_first}List(){
        return this.${column.javaField}List;
    }

    /**
    * 设置 ${column.columnComment}
    * @param ${column.javaField}List
    */
    public void set${column.javaField?cap_first}List(List<${column.javaType}> ${column.javaField}List){
        this.${column.javaField}List = ${column.javaField}List;
    }

    </#if>
    <#if column.javaType == "String">
    /**
    * 获取 ${column.columnComment}
    * @return ${column.javaField}List
    */
    public List<${column.javaType}> get${column.javaField?cap_first}List(){
        return this.${column.javaField}List;
    }

    /**
    * 设置 ${column.columnComment}
    * @param ${column.javaField}List
    */
    public void set${column.javaField?cap_first}List(List<${column.javaType}> ${column.javaField}List){
        this.${column.javaField}List = ${column.javaField}List;
    }
    </#if>
    <#if column.javaType == "Date">
    /**
    * 获取 开始 ${column.columnComment}
    * @return ${column.javaField}Start
    */
    public String get${column.javaField?cap_first}Start(){
        return this.${column.javaField}Start;
    }

    /**
    * 设置 开始 ${column.columnComment}
    * @param ${column.javaField}Start
    */
    public void set${column.javaField?cap_first}Start(String ${column.javaField}Start){
        this.${column.javaField}Start = ${column.javaField}Start;
    }

    /**
    * 获取 结束 ${column.columnComment}
    * @return ${column.javaField}End
    */
    public String get${column.javaField?cap_first}End(){
        return this.${column.javaField}End;
    }

    /**
    * 设置 结束 ${column.columnComment}
    * @param ${column.javaField}End
    */
    public void set${column.javaField?cap_first}End(String ${column.javaField}End){
        this.${column.javaField}End = ${column.javaField}End;
    }

    </#if>
</#list>
<#list columns as column>
    <#if column.javaType == "Long"||column.javaType == "Integer"||column.javaType == "BigDecimal">
    /**
    * 设置  ${column.columnComment}
    * @param ${column.javaField}
    */
    public ${ClassName}Entity ${column.javaField}(${column.javaType} ${column.javaField}){
	    set${column.javaField?cap_first}(${column.javaField});
		return this;
    }
    /**
    * 设置 开始 ${column.columnComment}
    * @param ${column.javaField}Start
    */
    public ${ClassName}Entity ${column.javaField}Start(${column.javaType} ${column.javaField}Start){
		this.${column.javaField}Start = ${column.javaField}Start;
		return this;
    }
    /**
    * 设置 结束 ${column.columnComment}
    * @param ${column.javaField}End
    */
    public ${ClassName}Entity ${column.javaField}End(${column.javaType} ${column.javaField}End){
		this.${column.javaField}End = ${column.javaField}End;
		return this;
    }
    /**
    * 设置 增加 ${column.columnComment}
    * @param ${column.javaField}Increment
    */
    public ${ClassName}Entity ${column.javaField}Increment(${column.javaType} ${column.javaField}Increment){
		this.${column.javaField}Increment = ${column.javaField}Increment;
		return this;
    }
    /**
    * 设置 ${column.columnComment}
    * @param ${column.javaField}List
    */
    public ${ClassName}Entity ${column.javaField}List(List<${column.javaType}> ${column.javaField}List){
        this.${column.javaField}List = ${column.javaField}List;
		return this;
    }
    </#if>
    <#if column.javaType  == "String">
	/**
    * 设置 ${column.columnComment}
    * @param ${column.javaField}
    */
    public ${ClassName}Entity ${column.javaField}(${column.javaType} ${column.javaField}){
        set${column.javaField?cap_first}(${column.javaField});
		return this;
    }

    /**
    * 设置 ${column.columnComment}
    * @param ${column.javaField}List
    */
    public ${ClassName}Entity ${column.javaField}List(List<${column.javaType}> ${column.javaField}List){
        this.${column.javaField}List = ${column.javaField}List;
		return this;
    }

    </#if>
    <#if column.javaType == "java.util.Date">
    /**
    * 设置 开始 ${column.columnComment}
    * @param ${column.javaField}Start
    */
    public ${ClassName}Entity ${column.javaField}Start(String ${column.javaField}Start){
		this.${column.javaField}Start = ${column.javaField}Start;
		return this;
    }

    /**
    * 设置 结束 ${column.columnComment}
    * @param ${column.javaField}End
    */
    public ${ClassName}Entity ${column.javaField}End(String ${column.javaField}End){
		this.${column.javaField}End = ${column.javaField}End;
		return this;
    }

    </#if>
</#list>
    /**
    * 获取 OR条件集合，列表项之间是OR，项内容之间是AND，如：(list[0].1 and list[0].2) or (list[1].3 and list[1].4)
    * @return orConditionList
    */
    public List<${ClassName}Entity> getOrConditionList(){
        return this.orConditionList;
    }

    /**
    * 设置 OR条件集合，列表项之间是OR，项内容之间是AND，如：(list[0].1 and list[0].2) or (list[1].3 and list[1].4)
    * @param orConditionList
    */
    public ${ClassName}Entity setOrConditionList(List<${ClassName}Entity> orConditionList){
        this.orConditionList = orConditionList;
        return this;
    }

    /**
    * 获取 AND条件集合，列表项之间是AND，项内容之间是OR，如：(list[0].1 or list[0].2) and (list[1].3 or list[1].4)
    * @return andConditionList
    */
    public List<${ClassName}Entity> getAndConditionList(){
        return this.andConditionList;
    }

    /**
    * 设置 AND条件集合，列表项之间是AND，项内容之间是OR，如：(list[0].1 or list[0].2) and (list[1].3 or list[1].4)
    * @param andConditionList
    */
    public ${ClassName}Entity setAndConditionList(List<${ClassName}Entity> andConditionList){
        this.andConditionList = andConditionList;
        return this;
    }

    @Override
    public int hashCode() {
         return this.getId().hashCode();
    }
    @Override
    public boolean equals(Object obj) {
        if (obj == null) return false;
        if (obj instanceof ${ClassName}Entity) {
            ${ClassName}Entity tmp = (${ClassName}Entity) obj;
            if (this.getId() == tmp.getId()) {
                 return true;
            }
        }
        return false;
    }

    public String toString(){
        StringBuilder sb = new StringBuilder("");
        <#list columns as column>
        <#if !column.isSuperColumn(column.javaField)>
        sb.append(",${column.javaField}:").append(get${column.javaField?cap_first}());
       </#if>
        </#list>
        return sb.toString();
    }

    public void initAttrValue(){
    <#list columns as column>
        <#if !column.isSuperColumn(column.javaField)>
        <#if column.javaType=="Long" && column.defaultValue??&& column.defaultValue!="">
            <#assign Default>${column.defaultValue}L</#assign>
        <#elseif column.javaType=="Integer" && column.defaultValue?? && column.defaultValue!="">
            <#assign Default>${column.defaultValue}</#assign>
        <#elseif column.javaType=="String" && column.defaultValue??>
            <#assign Default>"${column.defaultValue}"</#assign>
        <#elseif column.javaType=="BigDecimal" && column.defaultValue??&& column.defaultValue!="">
            <#assign Default>BigDecimal.valueOf(${column.defaultValue})</#assign>
        <#elseif column.javaType=="Date" >
            <#assign Default>null</#assign>
        <#else>
            <#assign Default>null</#assign>
        </#if>
            this.${column.javaField} = ${Default};
        </#if>
    </#list>
    }
}