package cn.axzo.workflow.common.enums;

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

/**
 * 抄送对象类型枚举
 *
 * @author wangli
 * @since 12/03/2024 09:33
 */
public enum CarbonCopyObjectType {
    // 单位下
    ent_role("ent_role", "role", "单位内指定角色", "entWorkspaceProcessor"),
    ent_position("ent_position", "position", "单位内指定岗位", "entWorkspaceProcessor"),
    ent_identity("ent_identity", "identity", "单位内指定身份", "entWorkspaceProcessor"),

    // 项目下
    project_role("project_role", "role", "项目部内指定角色", "projectWorkspaceProcessor"),
    project_position("project_position", "position", "项目部内指定岗位", "projectWorkspaceProcessor"),
    project_identity("project_identity", "identity", "项目部内指定身份", "projectWorkspaceProcessor"),

    // 特殊的指定人员
    specify_user("specify_user", "specify_user", "指定人员", "common"),

    approver_relation("approver_relation", "approver_relation", "审批相关人员", "common"),
    // 以下 4 个是 approver_relation 的选项值
    initiator("initiator", "initiator", "发起人", "common"),
    approver("approver", "approver", "审批人", "common"),
    ent_initiator_leader("ent_initiator_leader", "initiatorLeader", "单位内发起人主管", "entWorkspaceProcessor"),
    project_initiator_leader("project_initiator_leader", "initiatorLeader", "项目部内发起人主管", "projectWorkspaceProcessor"),
    ;

    private String type;
    private String simpleType;
    private String desc;
    private String processor;

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

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public String getSimpleType() {
        return simpleType;
    }

    public void setSimpleType(String simpleType) {
        this.simpleType = simpleType;
    }

    public String getDesc() {
        return desc;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }

    public String getProcessor() {
        return processor;
    }

    public void setProcessor(String processor) {
        this.processor = processor;
    }

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

}
