package jnpf.authority.utils;

import lombok.Getter;
import lombok.RequiredArgsConstructor;

/**
 * 权限适用范围枚举
 *
 * @author wangchunxiang
 * @date 2025/06/05
 */
@Getter
@RequiredArgsConstructor
public enum PermissionsApplicableEnums {
    // 权限适用范围,0全部1所在组织和下级组织员工,2所在组织员工,3仅下属,4指定组织
    ALL("0", "全部"),
    SCOPE_ORGANIZATION_AND_SUBORDINATE_EMPLOYEES("1", "所在组织和下级组织员工"),
    SCOPE_ORGANIZATION_EMPLOYEES("2", "所在组织员工"),
    SCOPE_SUBORDINATE("3", "仅下属"),
    SCOPE_SPECIFIC_ORGANIZATION("4", "指定组织");

    private final String value;
    private final String name;

    /**
     * 根据 value 获取枚举
     */
    public static PermissionsApplicableEnums fromValue(String value) {
        for (PermissionsApplicableEnums e : PermissionsApplicableEnums.values()) {
            if (e.getValue().equals(value)) {
                return e;
            }
        }
        throw new IllegalArgumentException("No enum constant with value: " + value);
    }

}
