package com.fjhx.enums;

import lombok.Getter;

import java.util.HashMap;

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

    WAIT(0, "待审批"),
    UNDER_WAY(1, "审批中"),
    ADOPT(2, "已审批"),
    REJECT(3, "已驳回"),
    WITHDRAW(4, "已撤回");

    private final Integer type;
    private final String name;

    private static final HashMap<Integer, FlowStatusEnum> map = new HashMap<>();

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

    static {
        for (FlowStatusEnum value : FlowStatusEnum.values()) {
            map.put(value.getType(), value);
        }
    }

    /**
     * 根据type获取枚举
     */
    public static FlowStatusEnum get(Integer type) {
        return map.get(type);
    }

    /**
     * 根据type值获取枚举
     */
    public static String getName(Integer type) {
        return map.get(type).getName();
    }

}
