package cn.reghao.bnt.web.admin.model.vo;

import cn.reghao.bnt.web.admin.model.po.Menu;
import lombok.Getter;
import lombok.Setter;

import java.util.List;

/**
 * @author reghao
 * @date 2024-07-01 13:58:30
 */
@Setter
@Getter
public class MenuTree {
    private Integer pid;
    private Integer id;
    private String name;
    private String menuName;
    private String url;
    private String icon;
    private String type;
    private Integer pos;
    private boolean visible;
    private List<MenuTree> children;
    // 授予了访问权限
    private boolean granted;
    private boolean open;
    private Integer grantedRoles;

    public MenuTree(Menu menu) {
        this.pid = menu.getPid();
        this.id = menu.getId();
        this.name = menu.getName();
        this.menuName = menu.getMenuName();
        this.url = menu.getUrl();
        this.icon = menu.getIcon();
        this.type = menu.getType();
        this.pos = menu.getPos();
        this.visible = menu.getVisible();
        //this.children = new ArrayList<>();
        this.granted = false;
        this.open = false;
        this.grantedRoles = menu.getRoles().size();
    }
}
