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.alibaba.fastjson.annotation.JSONField;
     <#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>
    @JSONField(serialize = false)
    </#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>

    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>

    @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>
    }
}