package com.mortals.xhx.module.demotree.model;

import java.util.List;
import java.util.ArrayList;
import com.mortals.xhx.module.demotree.model.vo.DemotreeVo;
import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.Data;
import java.io.Serializable;
import java.util.stream.Collectors;
/**
* 树信息前端映射树结构实体类
*
* @author zxfei
* @date 2021-11-26
*/

public class DemotreeTreeSelect  implements Serializable {
    private static final long serialVersionUID = 1L;

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

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

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

    public DemotreeTreeSelect(DemotreeEntity entity) {
        this.id = entity.getId();
        this.label = entity.getTreeName();
        this.children = entity.getChildren().stream().map(DemotreeTreeSelect::new).collect(Collectors.toList());
    }

}