package com.dcsoft.system.domain.vo;

import com.dcsoft.system.domain.SysBranch;
import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.Data;

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

@Data
public class TreeSelectVo {
    /** 节点ID */
    private String id;

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

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

    /** 父级Id */
    private String parentId;


    public TreeSelectVo()
    {

    }

    public TreeSelectVo(SysBranch branch) {
        this.id = branch.getId();
        this.label = branch.getName();
        this.children = branch.getChildren().stream().map(TreeSelectVo::new).collect(Collectors.toList());
    }
}
