package ${packageName}.domain;

import lombok.Data;
    #if($importList)
        #foreach ($import in $importList)
        import ${import};
        #end
    #end
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.dcs.common.annotation.Excel;
    #if($table.crud || $table.sub)
    import com.dcs.common.core.domain.BaseEntity;
        #elseif($table.tree)
    import com.dcs.common.core.domain.TreeEntity;
    #end

    #set($hasDate = false)
    #foreach($col in $columns)
        #if($col.javaType == "Date")
            #set($hasDate = true)
            #break
        #end
    #end
    #if($hasDate)
    import com.fasterxml.jackson.annotation.JsonFormat;
    #end

    #if($table.sub)
    import java.util.List;
    #end

    ## 新增 MyBatis Plus 注解
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.IdType;

/**
 * ${functionName}对象 ${tableName}
 *
 * @author ${author}
 * @date ${datetime}
 */
#if($table.crud || $table.sub)
    #set($Entity="BaseEntity")
    #elseif($table.tree)
    #set($Entity="TreeEntity")
#end

@Data
@TableName("${tableName}")
public class ${ClassName} extends ${Entity} {

    private static final long serialVersionUID = 1L;

#foreach ($column in $columns)
    #if(!$table.isSuperColumn($column.javaField))
    /** $column.columnComment */
    #if($column.list)
        #set($parentheseIndex=$column.columnComment.indexOf("（"))
            #if($parentheseIndex != -1)
                #set($comment=$column.columnComment.substring(0, $parentheseIndex))
            #else
                #set($comment=$column.columnComment)
            #end
            #if($parentheseIndex != -1)
            @Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()")
            #elseif($column.javaType == 'Date')
            @JsonFormat(pattern = "yyyy-MM-dd")
            @Excel(name = "${comment}", width = 30, dateFormat = "yyyy-MM-dd")
            #else
            @Excel(name = "${comment}")
            #end
        #end
        ## 确保只为主键字段加 @TableId，其他字段不加注解
        #if($column.isPk == "1")
        @TableId(value = "$column.columnName", type = IdType.AUTO)
        #else
            ## 只有当字段名与数据库列名不一致时，加上 @TableField 注解
            #if($column.columnName.toLowerCase() != $column.javaField.toLowerCase())
            @TableField(value = "$column.columnName")
            #end
        #end
    private $column.javaType $column.javaField;

    #end
#end

#if($table.sub)
/**
 * ${table.subTable.functionName}信息
 */
private List<${subClassName}> ${subclassName}List;
#end
        }
