package com.njcn.supervision.enums;

import lombok.Getter;

import java.util.Objects;

/**
 * 流程审批状态
 */
@Getter
public enum FlowStatusEnum {

    NEW(0, "待提交审批"),
    AUDIT(1, "审批中"),
    APPROVE(2, "审批通过"),
    OPPOSE(3, "审批不通过"),
    CANCEL(4, "已取消"),
    NO_FEEDBACK(5, "未反馈"),
    UN_TEST(6, "待测试");

    private final Integer code;

    private final String name;

    FlowStatusEnum(Integer code, String name) {
        this.code = code;
        this.name = name;
    }


    public static String getNameByCode(Integer code) {
        for (FlowStatusEnum userNatureEnum : FlowStatusEnum.values()) {
            if (Objects.equals(userNatureEnum.code, code)) {
                return userNatureEnum.name;
            }
        }
        return "";
    }


    public static Integer getCodeByName(String name) {
        for (FlowStatusEnum userNatureEnum : FlowStatusEnum.values()) {
            if (userNatureEnum.name.equalsIgnoreCase(name)) {
                return userNatureEnum.code;
            }
        }
        return 0;
    }
}
