LeaveTodoTypeEnum.java 1.63 KB
package cn.fw.valhalla.domain.enums;

import com.baomidou.mybatisplus.core.enums.IEnum;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.Getter;

/**
 * @author : kurisu
 * @className : LeaveTodoTypeEnum
 * @description : 人员变动待处理事件类型
 * @date: 2020-08-11 17:37
 */
public enum LeaveTodoTypeEnum implements IEnum<Integer> {
    /**
     * 客户待分配
     */
    CUSTOMER(10, "客户待分配"),
    /**
     * 其他
     */
    OTHER(20, "其他"),
    ;

    /**
     * 值
     */
    private final Integer value;
    /**
     * 名称
     */
    @Getter
    private final String name;

    LeaveTodoTypeEnum(final Integer value, final String name) {
        this.value = value;
        this.name = name;
    }

    /**
     * 根据枚举值获取枚举对象
     */
    @JsonCreator
    public static LeaveTodoTypeEnum ofValue(final Integer value) {
        for (final LeaveTodoTypeEnum typeEnum : LeaveTodoTypeEnum.values()) {
            if (typeEnum.value.equals(value)) {
                return typeEnum;
            }
        }
        return null;
    }

    /**
     * 获取值
     *
     * @return 值
     */
    @JsonValue
    @Override
    public Integer getValue() {
        return value;
    }

    /**
     * 获取描述
     *
     * @return 值
     */
    @JsonCreator
    public static String getNameByVale(final Integer value) {
        for (final LeaveTodoTypeEnum typeEnum : LeaveTodoTypeEnum.values()) {
            if (typeEnum.value.equals(value)) {
                return typeEnum.getName();
            }
        }
        return "";
    }
}