package com.diagbot.enums;

import com.diagbot.core.KeyedNamed;
import lombok.Setter;

/**
 * 
 * @Description: 计费方式枚举类型
 * @author wangfeng
 * @date 2018年9月27日 下午4:21:19
 */
public enum ChargeTypeEnum implements KeyedNamed {
    ByFlow(1, "按流程计费"),
    ByOrginations(2, "按机构计费"),
    ByUser(3,"按用户计费");

    @Setter
    private Integer key;

    @Setter
    private String name;

    ChargeTypeEnum(Integer key, String name) {
        this.key = key;
        this.name = name;
    }

    public static ChargeTypeEnum getEnum(Integer key) {
        for (ChargeTypeEnum item : ChargeTypeEnum.values()) {
            if (item.key == key) {
                return item;
            }
        }
        return null;
    }

    public static String getName(Integer key) {
        ChargeTypeEnum item = getEnum(key);
        return item != null ? item.name : null;
    }

    @Override
    public int getKey() {
        return key;
    }

    @Override
    public String getName() {
        return name;
    }
}

