package com.zcloud.safetyDutyList.domain.enums;

import lombok.Getter;

import java.util.Arrays;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;

/**
 * 菜单枚举
 */
@Getter
public enum MenuEnum {
    // 重点作业情况统计
    jgdzdzyqktj("/KeyProject/container/supervision/keyStats/list", "jgd-zdzyqktj");

    private final String path;
    private final String menuKey;

    private static final Map<String, MenuEnum> PATH_MAP =
            Arrays.stream(values())
                    .collect(Collectors.toMap(MenuEnum::getPath, Function.identity()));

    MenuEnum(String path, String menuKey) {
        this.path = path;
        this.menuKey = menuKey;
    }

    public String getPath() {
        return path;
    }

    public String getMenuKey() {
        return menuKey;
    }

    // 通过name获取枚举
    public static MenuEnum getByPath(String path) {
        return PATH_MAP.get(path);
    }

    // 通过path获取age
    public static String getMenuKeyByPath(String path) {
        MenuEnum entry = PATH_MAP.get(path);
        return entry != null ? entry.getMenuKey() : null;
    }

}
