ApproveTypeEnum.java 1.6 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 : ApproveTypeEnum
 * @description : 审批类型
 * @date: 2020-10-15 17:37
 */
public enum ApproveTypeEnum implements IEnum<Integer> {
    /**
     * 等待回调
     */
    FOLLOW_DEFEAT(1, "跟进战败"),
    /**
     * 完成回调
     */
    OTHER(2, "其他"),
    ;

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

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

    /**
     * 根据枚举值获取枚举对象
     */
    @JsonCreator
    public static ApproveTypeEnum ofValue(final Integer value) {
        for (final ApproveTypeEnum typeEnum : ApproveTypeEnum.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 ApproveTypeEnum typeEnum : ApproveTypeEnum.values()) {
            if (typeEnum.value.equals(value)) {
                return typeEnum.getName();
            }
        }
        return "";
    }
}