package com.fjhx.enums;

import lombok.Getter;

import java.util.HashMap;

/**
 * 合同付款类型
 */
@Getter
public enum ContractPayTypeEnum {

    ACCOUNTING_PERIOD(0, "有账期"),
    ADVANCE_CHARGE(1, "预付款");

    private final Integer type;
    private final String name;

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

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

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

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

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


}
