package com.yh.saas.plugin.clouddisk.entity;

import com.baomidou.mybatisplus.annotations.TableField;
import com.baomidou.mybatisplus.annotations.TableId;
import com.baomidou.mybatisplus.annotations.TableName;
import com.baomidou.mybatisplus.enums.IdType;
import com.winsea.svc.base.base.util.tree.ITreeItem;
import com.yh.saas.common.support.entity.BaseModel;
import com.yh.saas.common.support.util.query.SearchField;
import com.yh.saas.common.support.util.query.SearchMode;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.io.Serializable;
import java.util.List;

@Data
@EqualsAndHashCode(callSuper = true)
@TableName(value = "sysmgr_data_manager_folder")
public class DataManagerFolder extends BaseModel<DataManagerFolder> implements ITreeItem<DataManagerFolder> {

    /**
     * 主键id
     */
    @TableId(type = IdType.INPUT)
    private String folderId;

    /**
     * 公司id
     */
    @SearchField(value = "comp_id", mode = SearchMode.EQ)
    private String compId;

    /**
     * 父级文件夹名称 如果是第一级就-1CommonParameterMapper
     */
    @SearchField(value = "parent_folder_id", mode = SearchMode.EQ)
    private String parentFolderId;

    /**
     * 文件夹名称
     */
    private String name;

    /**
     * 子级
     */
    @TableField(exist = false)
    private List<DataManagerFolder> childList;

    /**
     * 编辑状态
     */
    @TableField(exist = false)
    private boolean editFlag;

    @Override
    protected Serializable pkVal() {
        return this.folderId;
    }

    @Override
    public Object getId() {
        return this.folderId;
    }

    @Override
    public void setId(Object id) {
        this.setFolderId(id.toString());
    }

    @Override
    public String getLabel() {
        return null;
    }

    @Override
    public void setLabel(String label) {

    }

    @Override
    public Object getParentId() {
        return this.parentFolderId;
    }

    @Override
    public void setParentId(Object parentId) {
        this.setParentFolderId(parentFolderId);
    }

    @Override
    public Integer getIndex() {
        return null;
    }

    @Override
    public void setIndex(Integer index) {

    }

    @Override
    public List<DataManagerFolder> getChildren() {
        return this.childList;
    }

    @Override
    public void setChildren(List<DataManagerFolder> children) {
        this.setChildList(children);
    }

    public static class QueryFields {

        public static final String FOLDER_NAME = "name";

        public static final String CREATE_DATE = "create_date";

        public static final String PARENT_FOLDER_ID = "parent_folder_id";

        public static final String FOLDER_ID = "folder_id";

        public static final String COMP_ID = "comp_id";

    }


}
