package com.ensign.crm.module.system.constant;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @Classname UserFunctionRoleEnum
 * @Description
 *
 * 1:厂家后台，
 * 2:区域经理，
 * 3:业务经理，
 * 4:经销商后台，
 * 5:经销商销售员
 *
 * @Date 2024/10/15 11:41
 * @Created by violet
 */

@Getter
@AllArgsConstructor
public enum UserFunctionRoleEnum {

    FACTORY_BACKEND(1, "CRM_role_1"),
    REGIONAL_MANAGER(2, "CRM_role_2"),
    BUSINESS_MANAGER(3, "CRM_role_3"),
    DEALER_BACKEND(4, "CRM_role_4"),
    DEALER_SALESMAN(5, "CRM_role_5");

    private final Integer userFunc;

    private final String roleName;


    private static final Map<Integer, String> MAP = new HashMap<>();

    private static final List<String> LIST = new ArrayList<>();

    static {
        for (UserFunctionRoleEnum role : UserFunctionRoleEnum.values()) {
            MAP.put(role.getUserFunc(), role.getRoleName());
            LIST.add(role.getRoleName());
        }
    }

    public static String getRoleName(Integer userFunc) {
        return MAP.get(userFunc);
    }

    public static List<String> getAllRoleName() {
        return LIST;
    }

    public static List<String> get(Integer... func) {
        List<String> roleNames = new ArrayList<>();
        for (Integer f : func) {
            String roleName = UserFunctionRoleEnum.getRoleName(f);
            if (roleName != null) {
                roleNames.add(roleName);
            }
        }
        return roleNames;
    }
}
