package com.zcloud.basic.info.domain.enums;

import lombok.Getter;

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

/**
 * @author zhangyue
 * @date 2025/12/6 13:48
 */
@Getter
public enum MenuEnum {
    QYYHZT("/basicInfo/container/supervision/enterpriseMiddleground/list", "qyyhzt"),
    ZZJG("/basicInfo/container/supervision/supervision/department", "jgzzjg"),
    GWGL("/basicInfo/container/supervision/supervision/post", "gwgl"),
    ZHGL2("/basicInfo/container/supervision/supervision/user/list", "zhgl2"),
    ZGSZHGL("/basicInfo/container/supervision/branchCompany/accountManage/list", "zgszhgl"),
    ZGSQYXXGL("/basicInfo/container/supervision/branchCompany/enterpriseInfo/list", "zgsqyxxgl"),
    ZGSBMGL("/basicInfo/container/supervision/branchCompany/departmentManage/list", "zgsbmgl"),
    ZGSYHGL("/basicInfo/container/supervision/branchCompany/subsidiaryUser/list", "zgsyhgl"),
    GSZHXXGL("/basicInfo/container/supervision/stakeholderUnit/accountManage/list", "gszhxxgl"),
    RYXXGL("/basicInfo/container/supervision/stakeholderUnit/user/list", "ryxxgl"),
    TSZYZSGL("/basicInfo/container/supervision/stakeholderUnit/specialPersonnel/list", "tszyzsgl"),
    AQRYZSGLGFD("/basicInfo/container/supervision/stakeholderUnit/securityPersonnel/list", "aqryzsglgfd"),
    GFDQYXX("/basicInfo/container/supervision/supervision/corpInfo/info", "gfdqyxx"),
    QYXX("/basicInfo/container/enterprise/corpInfo/info", "qyxx"),
    ZZJGQYD("/basicInfo/container/enterprise/organizationStructure", "zzjgqyd"),
    GWGLQYD("/basicInfo/container/enterprise/post", "gwglqyd"),
    YHGLQYD("/basicInfo/container/enterprise/user/list", "yhglqyd"),
    QYDQYYHZT("/basicInfo/container/enterprise/enterpriseMiddleground/list", "qydqyyhzt"),
    QYDXGFZHGL("/basicInfo/container/enterprise/stakeholderUnit/accountManage/list", "qyd-xgf-zhgl"),
    QHDXGFYHGL("/basicInfo/container/enterprise/stakeholderUnit/user/list", "qyd-xgf-yhgl"),
    QYXXGL("/basicInfo/container/stakeholder/corpInfo", "qyxxgl"),
    BMGLXGF("/basicInfo/container/stakeholder/department", "bmglxgf"),
    YHGLXGF("/basicInfo/container/stakeholder/user/list", "yhglxgf"),
    TZZYZSGL("/Container/Stakeholder/SpecialOperationPersonnel", "tzzyzsgl"),
    AQRYZSGL("/Container/Stakeholder/SecurityPersonnelInfo", "aqryzsgl");

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

// 使用示例
    public static void main(String[] args) {
        // 获取整个枚举
        MenuEnum entry = MenuEnum.getByPath("张三");
        if (entry != null) {
            System.out.println("MenuKey: " + entry.getMenuKey()); // 输出: MenuKey: 25
        }

        // 直接获取值
        String age = MenuEnum.getMenuKeyByPath("李四");
        System.out.println("李四的年龄: " + age); // 输出: 李四的年龄: 30
    }
}
