package cn.axzo.workflow.common.enums;

import java.util.Arrays;
import java.util.Objects;

/**
 * 签署确认节点的审批人层级范围限制
 *
 * @author wangli
 * @since 2025-03-26 14:30
 */
public enum SignApproverOrgLimitEnum {
    LV_0("LV_0", "当前组织", 0),
    LV_1("LV_1", "上1级组织", 1),
    LV_2("LV_2", "上2级组织", 2),
    LV_3("LV_3", "上3级组织", 3),
    LV_4("LV_4", "上4级组织", 4),
    LV_5("LV_5", "上5级组织", 5),
    LV_ALL("LV_ALL", "所有组织", -1),
    LV_TOP("LV_TOP", "顶层组织", Integer.MAX_VALUE),
    UNKNOWN("UNKNOWN", "未知层级", null)
    ;

    private final String type;

    private final String desc;

    private final Integer code;

    SignApproverOrgLimitEnum(String type, String desc, Integer code) {
        this.type = type;
        this.desc = desc;
        this.code = code;
    }

    public String getType() {
        return type;
    }

    public String getDesc() {
        return desc;
    }

    public Integer getCode() {
        return code;
    }

    public static SignApproverOrgLimitEnum valueOfType(String type) {
        return Arrays.stream(SignApproverOrgLimitEnum.values())
                .filter(i -> Objects.equals(i.getType(), type))
                .findAny()
                .orElse(null);
    }
}
