package cc.smtweb.system.bpm.web.design.preview;

import cc.smtweb.system.bpm.util.ITreeDataLevelHandler;
import lombok.Data;

import java.util.List;

@Data
public class MenuVO {
    private Long id;
    private Long parentId;
    private int level;
    private String name;
    private String path;
    private String icon;
    private List<MenuVO> children;

    // 树结构数据句柄
    public static ITreeDataLevelHandler<MenuVO> createTreeHandler() {
        return new ITreeDataLevelHandler<MenuVO>() {
            @Override
            public Long getId(MenuVO node) {
                return node.getId();
            }

            @Override
            public Long getParentId(MenuVO node) {
                return node.getParentId();
            }

            @Override
            public List<MenuVO> getChildren(MenuVO node) {
                return node.children;
            }

            @Override
            public void setChildren(MenuVO node, List<MenuVO> children) {
                node.children = children;
            }

            @Override
            public int getLevel(MenuVO node) {
                return node.level;
            }

            @Override
            public void setLevel(MenuVO node, int level) {
                node.level = level;
            }
        };
    }
}
