package com.zcloud.domain.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 {
    //领域部门
    LYBMGL("/domain/container/supervision/domainDepartment", "lybmgl"),
    //领域组
    LYZGL("/domain/container/supervision/domainGroup", "lyzgl"),
    //课题任务管理
    GFDKTRW("/domain/container/supervision/projectTask/list", "gfd-ktrw"),
    //课题评分管理
    GFDKTPF("/domain/container/supervision/projectScore", "gfd-ktpf"),


    //企业端
    //课题任务管理
    QYDKTRW("/domain/container/branchCompany/projectTask/list", "qyd-ktrw"),
    //课题评分管理
    QYDKTPF("/domain/container/branchCompany/projectScore", "qyd-ktpf"),

    ;

    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;
    }

}
