package com.keyware.shandan.bianmu.entity;

import com.baomidou.mybatisplus.annotation.*;
import com.keyware.shandan.bianmu.enums.DirectoryPermisScope;
import com.keyware.shandan.bianmu.enums.DirectoryType;
import com.keyware.shandan.bianmu.enums.ReviewStatus;
import com.keyware.shandan.common.entity.BaseEntity;
import com.keyware.shandan.system.entity.SysOrg;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;

import java.util.Date;
import java.util.List;

/**
 * <p>
 * 目录表
 * </p>
 *
 * @author GuoXin
 * @since 2021-06-01
 */
@Data
@EqualsAndHashCode(callSuper = true)
@NoArgsConstructor
@TableName(value = "B_DIRECTORY", resultMap = "BaseResultMap")
public class DirectoryVo extends BaseEntity {

    private static final long serialVersionUID = 2800844298381044177L;

    /**
     * 主键
     */
    @TableId("ID")
    private String id;

    /**
     * 目录名称
     */
    @TableField(value = "DIRECTORY_NAME", condition = SqlCondition.LIKE)
    private String directoryName;

    /**
     * 父目录ID
     */
    @TableField("PARENT_ID")
    private String parentId;

    /**
     * 目录路径
     */
    @TableField("DIRECTORY_PATH")
    private String directoryPath;

    /**
     * 目录类型
     */
    @TableField("DIRECTORY_TYPE")
    private DirectoryType directoryType;

    /**
     * 数据密级
     */
    @TableField("SECRET_LEVEL")
    private Integer secretLevel;

    /**
     * 资源ID
     * 当目录类型为DIRECTORY时，该字段值为null
     * 当目录类型为METADATA时，该字段值为数据资源ID
     * 当目录类型为FILE时，该字段值为文件ID
     * 当目录类型为LINK时，该字段值为引用的目录ID
     */
    @TableField("RESOURCE_ID")
    private String resourceId;

    /**
     * 是否为基础数据目录
     */
    @TableField("IS_BASIC_DIR")
    private boolean basicDir;

    /**
     * 数据审核状态（'UN_SUBMIT'：未提交，'SUBMITTED'：已提交，'PASS'：审核通过，'FAIL'：审核未通过）
     */
    @TableField("REVIEW_STATUS")
    private ReviewStatus reviewStatus;

    /**
     * 所属部门ID
     */
    @TableField(value = "ORG_ID", fill = FieldFill.INSERT)
    private String orgId;

    /**
     * 目录拥有者
     */
    @TableField(value = "OWNER")
    private String owner;

    /**
     * 目录拥有者类型，user：系统用户，org：部门
     */
    @TableField(value = "OWNER_TYPE")
    private String ownerType;

    /**
     * 目录拥有者ID
     */
    @TableField(value = "OWNER_ID")
    private String ownerId;

    @TableField(value = "PERMIS_EVERYONE")
    private String permisEveryone;
    @TableField(value = "PERMIS_ALL_PARENT")
    private String permisAllParent;
    @TableField(value = "PERMIS_PARENT")
    private String permisParent;
    @TableField(value = "PERMIS_ALL_CHILD")
    private String permisAllChild;
    @TableField(value = "PERMIS_CHILD")
    private String permisChild;

    /**
     * 创建时间
     */
    @TableField(value = "CREATE_TIME", fill = FieldFill.INSERT)
    @OrderBy(isDesc = false)
    private Date createTime;

    @TableField(exist = false)
    private String modifyUserName;

    /**
     * 子级目录
     */
    @TableField(exist = false)
    private List<DirectoryVo> children;

    /**
     * 权限设置是否应用到下级目录
     */
    @TableField(exist = false)
    private boolean applyChild;

    /**
     * 目录顺序
     */
    @TableField(value = "SORT")
    private Integer sort;

    /**
     * 创建人名称
     */
    @TableField(exist = false)
    private String createUserName;

    @Builder
    public DirectoryVo(String id, String directoryName, String parentId, String directoryPath, DirectoryType directoryType, String resourceId, ReviewStatus reviewStatus, String orgId, String owner, String ownerType, String ownerId, String permisEveryone, String permisAllParent, String permisParent, String permisAllChild, String permisChild) {
        this.id = id;
        this.directoryName = directoryName;
        this.parentId = parentId;
        this.directoryPath = directoryPath;
        this.directoryType = directoryType;
        this.resourceId = resourceId;
        this.reviewStatus = reviewStatus;
        this.orgId = orgId;
        this.owner = owner;
        this.ownerType = ownerType;
        this.ownerId = ownerId;
        this.permisEveryone = permisEveryone;
        this.permisAllParent = permisAllParent;
        this.permisParent = permisParent;
        this.permisAllChild = permisAllChild;
        this.permisChild = permisChild;
    }
}
