package cn.axzo.workflow.common.enums;

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

/**
 * 审批人所在范围枚举
 *
 * @author wangli
 * @since 2023/11/16 10:14
 */
public enum ApproverScopeEnum {
    entWorkspace("entWorkspace", "企业工作台", "entWorkspaceProcessor"),
    projectWorkspace("projectWorkspace", "项目工作台","projectWorkspaceProcessor"),
    preTaskUser("preTaskUser", "上节点审批人所在单位","preTaskUserProcessor"),
    preTaskSpecified("preTaskSpecified", "上节点审批人指定","preTaskUserProcessor"),
    ;
    private final String type;
    private final String desc;
    private final String processor;

    ApproverScopeEnum(String type, String desc, String processor) {
        this.type = type;
        this.desc = desc;
        this.processor = processor;
    }

    public String getType() {
        return type;
    }

    public String getDesc() {
        return desc;
    }

    public String getProcessor() {
        return processor;
    }

    public boolean selectWorkspace() {
        return this == ApproverScopeEnum.projectWorkspace;
    }

    public static ApproverScopeEnum valueOfProcessor(String processor) {
        return Arrays.stream(ApproverScopeEnum.values())
                .filter(i -> Objects.equals(i.getProcessor(), processor))
                .findAny()
                .orElse(null);
    }
}
