package cn.pluss.platform.entity;

import cn.pluss.platform.config.mybatis.SqlConditionExtra;
import cn.pluss.platform.util.tree.BaseNode;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import lombok.Data;
import lombok.experimental.Accessors;

import java.util.Date;

/**
 * @author djh
 * create sql:
 * CREATE TABLE `tb_pluss_dict` (
 *   `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'id',
 *   `pid` int(11) DEFAULT NULL COMMENT '父级id',
 *   `sort` int(11) DEFAULT NULL COMMENT '排序',
 *   `code` varchar(50) DEFAULT NULL COMMENT '字典code',
 *   `name` varchar(20) DEFAULT NULL COMMENT '名称',
 *   `desc` varchar(50) DEFAULT NULL COMMENT '描述',
 *   `createTime` datetime DEFAULT NULL COMMENT '创建时间',
 *   `updateTime` datetime DEFAULT NULL COMMENT '更新时间',
 *   PRIMARY KEY (`id`),
 *   UNIQUE KEY `idx_code` (`code`) COMMENT 'code唯一'
 * ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='通用字典表';
 */
@Data
@Accessors(chain = true)
public class Dict extends BaseNode<Dict> {

    @TableField("`code`")
    private String code;

    @TableField(exist = false)
    private String pCode;

    @TableField("`name`")
    private String name;

    @TableField("`desc`")
    private String desc;

    @TableField("`value`")
    private String value;

    @TableField(exist = false)
    private String title;

    @TableField(fill = FieldFill.INSERT)
    private Date createTime;

    @TableField(select = false, value = "createTime", condition = SqlConditionExtra.GT)
    private Date createTimeStart;

    @TableField(select = false, value = "createTime", condition = SqlConditionExtra.LT)
    private Date createTimeEnd;

    @TableField(fill = FieldFill.INSERT_UPDATE)
    private Date updateTime;

    @TableField(select = false, value = "updateTime", condition = SqlConditionExtra.GT)
    private Date updateTimeStart;

    @TableField(select = false, value = "updateTime", condition = SqlConditionExtra.LT)
    private Date updateTimeEnd;
}
