package com.ruoyi.zongzhi.domain.vo;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.ruoyi.zongzhi.domain.TcTown;
import lombok.Data;

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

/**
 * Treeselect树结构实体类
 *
 * @author ruoyi
 */
@Data
public class TreeNode
{


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

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


    /** 父节点名称 */
    private String parentName;

    /** 父节点id*/
    Long  parentId;

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

    public TreeNode()
    {

    }

    public TreeNode(TcTown tcTown)
    {
        this.id = tcTown.getId();
        this.label = tcTown.getName();
        this.parentName=tcTown.getParentName();
        this.parentId=tcTown.getParentId();
        this.children = tcTown.getChildren().stream().map(TreeNode::new).collect(Collectors.toList());
    }



}
