package com.hz.pm.api.sys.enumeration;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import org.apache.commons.lang3.StringUtils;

import java.util.Objects;

/**
 *
 * 项目预警状态枚举
 * @author ZPF
 * @since 2023/02/24 16:14
 */
@Getter
@NoArgsConstructor
@AllArgsConstructor
public enum ProjectEarlyWarningStatusEnum {
    /**
     * 项目预警状态枚举
     */
    NORMAL(1, "正常"),
    OVER_TIME(2, "超期"),
    ADVENT_TIME(3, "临期");

    private Integer code;
    private String desc;

    public static String match(Integer code) {
        if (Objects.isNull(code)) {
            return StringUtils.EMPTY;
        }
        for (ProjectEarlyWarningStatusEnum t : ProjectEarlyWarningStatusEnum.values()) {
            if (code.equals(t.getCode())) {
                return t.desc;
            }
        }
        return StringUtils.EMPTY;
    }

    public static String getNameByCode(Integer code) {
        if (Objects.isNull(code)) {
            return StringUtils.EMPTY;
        }
        for (ProjectEarlyWarningStatusEnum t : ProjectEarlyWarningStatusEnum.values()) {
            if (code.equals(t.getCode())) {
                return t.name();
            }
        }
        return StringUtils.EMPTY;
    }
}
