package com.qmth.teachcloud.common.enums;

import java.util.Objects;

/**
 * @Description: 流程审批变量 enum
 * @Param:
 * @return:
 * @Author: wangliang
 * @Date: 2021/8/2
 */
public enum FlowApproveVariableEnum {

    PRIMARY_APPROVE("一级审核通过", "1"),

    PRIMARY_REJECT("一级审核驳回", "0"),

    SECOND_APPROVE("二级审核通过", "2"),

    SECOND_REJECT_ONE("二级审核驳回至第一节点", "0"),

    SECOND_REJECT_TWO("二级审核驳回至第二节点", "1");

    private String title;

    private String id;

    private FlowApproveVariableEnum(String title, String id) {
        this.title = title;
        this.id = id;
    }

    public String getTitle() {
        return title;
    }

    public String getId() {
        return id;
    }

    /**
     * 状态转换 toName
     *
     * @param title
     * @return
     */
    public static String convertToName(String title) {
        for (FlowApproveVariableEnum e : FlowApproveVariableEnum.values()) {
            if (Objects.equals(title, e.getTitle())) {
                return e.name();
            }
        }
        return null;
    }

    /**
     * 状态转换 toInstance
     *
     * @param id
     * @return
     */
    public static FlowApproveVariableEnum convertToInstance(String id) {
        for (FlowApproveVariableEnum e : FlowApproveVariableEnum.values()) {
            if (Objects.equals(id, e.getTitle())) {
                return e;
            }
        }
        return null;
    }
}
