package com.mortals.xhx.base.system.menu.model;

import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.Data;

import java.io.Serializable;
import java.util.List;
import java.util.stream.Collectors;
/**
* 菜单信息前端映射树结构实体类
*
* @author zxfei
* @date 2023-04-10
*/
@Data
public class MenuTreeSelect  implements Serializable {
    private static final long serialVersionUID = 1L;

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

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

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

    public MenuTreeSelect(MenuEntity entity) {
        this.id = entity.getId();
        this.label = entity.getName();
        this.children = entity.getChildList().stream().map(MenuTreeSelect::new).collect(Collectors.toList());
    }

}