package com.bonus.material.ma.vo;

import com.bonus.common.biz.domain.MaTypeProperty;
import com.fasterxml.jackson.annotation.JsonInclude;

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

/**
 * Treeselect树结构实体类
 *
 * @author ruoyi
 */
public class TreeSelect implements Serializable {
    private static final long serialVersionUID = 1L;

    /**
     * 节点ID
     */
    private Long id;

    /**
     * 节点名称
     */
    private String label;

    private Integer level;

    private Long parentId;

    private String companyId;

    private String unitName;

    private Boolean isStateGrid;

    private List<MaTypeProperty> maTypeProperties;

    /**
     * 子节点
     */
    @JsonInclude(JsonInclude.Include.NON_EMPTY)
    private List<TreeSelect> children;

    public TreeSelect() {

    }

//    public TreeSelect(MaHouse maHouse)
//    {
//        this.level = maHouse.getLevel();
//        this.id = maHouse.getHouseId();
//        this.label = maHouse.getHouseName();
//        this.children = maHouse.getChildren().stream().map(TreeSelect::new).collect(Collectors.toList());
//    }

    public TreeSelect(MaType maType) {
        this.parentId = maType.getParentId();
        this.level = Integer.valueOf(maType.getLevel());
        this.id = maType.getTypeId();
        this.label = maType.getTypeName();
        this.companyId = maType.getCompanyId();
        this.unitName = maType.getUnitName();
        this.maTypeProperties = maType.getMaTypeProperties();
        this.isStateGrid = maType.getIsStateGrid();
        this.children = maType.getChildren().stream().map(TreeSelect::new).collect(Collectors.toList());
    }
//    public TreeSelect(SysDept dept)
//    {
//        this.id = dept.getDeptId();
//        this.label = dept.getDeptName();
//        this.children = dept.getChildren().stream().map(TreeSelect::new).collect(Collectors.toList());
//    }


    public Boolean getStateGrid() {
        return isStateGrid;
    }

    public void setStateGrid(Boolean stateGrid) {
        isStateGrid = stateGrid;
    }

    public Long getParentId() {
        return parentId;
    }

    public void setParentId(Long parentId) {
        this.parentId = parentId;
    }


    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public Integer getLevel() {
        return level;
    }

    public void setLevel(Integer level) {
        this.level = level;
    }

    public String getLabel() {
        return label;
    }

    public void setLabel(String label) {
        this.label = label;
    }

    public String getCompanyId() {
        return companyId;
    }

    public void setCompanyId(String companyId) {
        this.companyId = companyId;
    }

    public String getUnitName() {
        return unitName;
    }

    public void setUnitName(String unitName) {
        this.unitName = unitName;
    }

    public List<MaTypeProperty> getMaTypeProperties() {
        return maTypeProperties;
    }

    public void setMaTypeProperties(List<MaTypeProperty> maTypeProperties) {
        this.maTypeProperties = maTypeProperties;
    }

    public List<TreeSelect> getChildren() {
        return children;
    }

    public void setChildren(List<TreeSelect> children) {
        this.children = children;
    }
}
