package com.thinkunion.park.service.common.baseentity;


import org.apache.commons.lang.StringUtils;

import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;

/**
 * @author 黄兵华
 * @date 2022/1/10 11:33
 * @describe
 */
public enum MenuTypeEnum {

    PARKING_LOT(1, "停车场", true),
    FIXED_CREWS_TAKE(2, "固定车组", true),
    CHARGING_RULES(3, "收费规则", true),
    RELEASE_RULES(4, "放行规则", true),
    CAR_INFO(5, "车辆信息", true),
    REVIEW_MONTHLY(6, "月卡审核", true),
    ACCESS_RECORDS(7, "出入记录", false),
    CORRECT_CAR_DATA(8, "余位矫正", false),
    STATISTICAL_ANALYSIS(9, "统计分析", false),
    PARKING_FAVORABLE(10, "停车优惠", false),
    CHARGE_MERCHANTS(11, "收费商户", true),
    MANAGEMENT_TOOL(12, "管理工具", true),
    INVOICE_RECORD(13, "开票记录", false),
    REFUND_APPROVE(14, "退款审核", true),
    REFUND_APPLY(15, "退款申请", false),

    PARK_INFO(16, "园区信息", false),
    SPACE_EQUIPMENT(17, "空间设备", false),
    ENTERPRISE_INFORMATION(18, "企业信息", false),
    PERSON_INFORMATION(19, "人员信息", false),
    MACHINE_INFORMATION(20, "设备信息", false),
    ALARM_TYPE(21, "报警类型", false),

    ROLE_MANAGEMENT(22, "角色管理", false),
    DATA_ACCESS(23, "数据权限", false),
    INTERFACE_ACCESS(24, "接口权限", false),

    PERSON_MANAGEMENT(25, "用户管理", false),
    DEPART_MANAGEMENT(26, "机构管理", false),
    JOBS_MANAGEMENT(27, "岗位管理", false),
    SYS_DICTIONARY(28, "系统字典", false),
    BUSINESS_DICTIONARY(29, "业务字典", false),
    MENU_MANAGEMENT(30, "菜单管理", false),
    TOP_MENU(31, "顶部菜单", false),

    PEOPLE_ACCESS_AUTH_track(32,"人员访问:人员轨迹",false),
    PEOPLE_ACCESS_AUTH_video_view(33,"人员访问:视频回放",false),
    PEOPLE_ACCESS_AUTH_video_down(34,"人员访问:视频下载",false),
    ERROR_TIME_AUDIT(35,"错时审核",true),
    LICENSE_PLATE_ALTERATION(36,"车牌变更",true),
    MONTH_LICENSE_PLATE_ALTERATION(36,"月卡车牌变更",true),

    ;

    private Integer value;

    private String desc;

    private boolean use;

    MenuTypeEnum(Integer value, String desc, boolean use) {
        this.value = value;
        this.desc = desc;
        this.use = use;
    }

    public Integer getValue() {
        return value;
    }

    public String getDesc() {
        return desc;
    }


    public static MenuTypeEnum getMenuTypeByValue(Integer value) {
        if (Objects.isNull(value)) {
            return null;
        }
        MenuTypeEnum[] menus = values();
        for (MenuTypeEnum menu : menus) {
            if (menu.getValue().equals(value)) {
                return menu;
            }
        }
        return null;
    }

    public static MenuTypeEnum getMenuTypeByDesc(String desc) {
        if (StringUtils.isBlank(desc)) {
            return null;
        }
        MenuTypeEnum[] menus = values();
        for (MenuTypeEnum menu : menus) {
            if (menu.getDesc().equals(desc)) {
                return menu;
            }
        }
        return null;
    }

    public static List<MenuTypeEnum> getUserMenuName() {
        MenuTypeEnum[] menus = values();
        return Arrays.stream(menus).filter(var -> var.use).collect(Collectors.toList());
    }

    public static List<Integer> getUseValue(){
        MenuTypeEnum[] menus=values();
        return Arrays.stream(menus).filter(var-> var.use).map(MenuTypeEnum::getValue).collect(Collectors.toList());
    }
}
