package com.diagbot.enums;

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

/**
 * @Description:服务端类型
 * @author: zhaops
 * @time: 2018/9/25 18:00
 */
public enum ServiceTypeEnum implements KeyedNamed {
    User_Create(1, "用户建立"),
    Sys_Create(2, "系统生成");

    @Setter
    private Integer key;

    @Setter
    private String name;

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

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

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

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

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