package com.fjhx.enums.supplier;

import lombok.Getter;

import java.util.HashMap;

@Getter
public enum AccountPeriodTypeEnum {

    ACCOUNTING_PERIOD(1, "有账期"),
    NO_ACCOUNTING_PERIOD(0, "无账期");

    private final Integer type;
    private final String name;

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

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

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

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

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

}
