package com.zcloud.fire.check.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 {
    //消防区域
    XFQYWH("/fireCheck/container/branchCompany/fireRegion", "xfqywh"),
    //消防点位
    XFDWWH("/fireCheck/container/branchCompany/firePoint", "xfdwwh"),
    //消防器材
    XFQCGL("/fireCheck/container/branchCompany/fireDevice", "xfqcgl"),
    //消防点检记录
    XFDJB("/fireCheck/container/branchCompany/fireCheckList/list", "xfdjb"),
    //点位检查记录
    DWJCJL("/fireCheck/container/branchCompany/fireCheckRecord/list", "dwjcjl"),
    //消防器材检查标准
    XFQCJCBZ("/fireCheck/container/supervision/fireCheckStandard", "xfqcjcbz"),
    //消防器材统计汇总
    XFQCTJHZ("/fireCheck/container/supervision/fireDeviceRecord/list", "xfqctjhz"),
    //分公司消防检查记录
    FGSXFJCJL("/fireCheck/container/supervision/fireRecords/list", "fgsxfjcjl"),

    ;

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