package ${package.Entity};

import cn.afterturn.easypoi.excel.annotation.Excel;
import com.baomidou.mybatisplus.annotation.*;
import java.io.Serializable;

import com.dk.common.infrastructure.annotaiton.ExportTitle;
import com.dk.common.infrastructure.handler.*;
import com.dk.common.model.pojo.PageInfo;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import lombok.AllArgsConstructor;
import lombok.NoArgsConstructor;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import com.alibaba.fastjson.JSONObject;

import java.util.List;
<#list table.importPackages as pkg>
<#if pkg == "java.util.Date" || pkg == "java.time.LocalDateTime">
import java.time.LocalDateTime;
</#if>
</#list>

<#if table.comment!="">
/**
 *  ${table.comment!}
 */
</#if>
@Data
@AllArgsConstructor
@NoArgsConstructor
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
<#if table.comment!="">
@ExportTitle("${table.comment!}")
</#if>
<#if table.comment=="">
@ExportTitle
</#if>
@TableName(value = "${table.name}", autoResultMap = true)
@ApiModel(value="实体类：${table.comment}", description="表名：${table.name}")
public class ${entity} extends PageInfo<${entity}> implements Serializable {

    /*
     * 数据库字段
     */
<#-- ----------  属性私有化  ---------->
<#list table.fields as field>
<#--    /*-->
<#--    *${field}-->
<#--    */-->
    <#if field.keyFlag>
        <#assign keyPropertyName="${field.propertyName}"/>
    </#if>

    <#if field.keyFlag>
    <#-- 主键 -->
    <#if field.comment!="">
    /**
     * ${field.comment!}
     */
    </#if>
    @TableId(value = "${field.name}", type = IdType.AUTO)
    <#-- 普通字段 -->
    <#elseif !field.keyFlag>
    <#if field.comment!="">
    /**
     * ${field.comment!}
     */
    </#if>
    </#if>
    <#--cpId-->
    <#if "cp_id" == field.name>
    @TableField(fill = FieldFill.INSERT)
    </#if>
    <#-- 乐观锁注解 -->
    <#if (versionFieldName!"") == field.name>
    @Version
    </#if>
    <#-- 逻辑删除注解 -->
<#--    <#if (logicDeleteFieldName!"") == field.name>-->
<#--    @TableLogic(value = "1", delval = "-1")-->
<#--    </#if>-->
    <#-- 创建时需要自动赋值的列 -->
    <#if !field.keyFlag && field.comment!="" && field.name !="value_flag" &&
    field.name !="update_user_id" &&  field.name !="create_user_id" && field.name !="op_create_time" &&  field.name !="op_update_time">
    @Excel(name = "${field.comment!}")
    </#if>
    <#if  field.name =="op_create_time" ||  field.name =="op_update_time">
    @Excel(name = "${field.comment!}", format = "yyyy-MM-dd HH:mm:ss", width = 20)
    </#if>
    @ApiModelProperty(value = "${field.comment!}")
    <#if field.propertyType =="Date">
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @TableField(typeHandler = TimestampTypeHandler.class)
    private LocalDateTime ${field.propertyName};
    <#elseif field.type == "bigint[]">
    @TableField(typeHandler = BigIntListTypeHandler.class)
    private List<Long> ${field.propertyName};
    <#elseif field.type == "int[]" || field.type == "integer[]">
    @TableField(typeHandler = IntListTypeHandler.class)
    private List<Integer> ${field.propertyName};
    <#elseif field.type == "uuid">
    @TableField(typeHandler = UuidTypeHandler.class)
    private ${field.propertyType} ${field.propertyName};
    <#elseif field.type == "uuid[]">
    @TableField(typeHandler = UuidListTypeHandler.class)
    private ${field.propertyType} ${field.propertyName};
    <#elseif field.type == "jsonb">
    @TableField(typeHandler = JsonTypeHandler.class)
    private JSONObject ${field.propertyName};
    <#else>
    private ${field.propertyType} ${field.propertyName};
    </#if>

</#list>

    /*
     * 相关属性
     * @TableField(exist = false)
     */

    /*
     * 关联属性 + 查询条件
     * @TableField(exist = false)
     */


    private static final long serialVersionUID = 1L;

}
