package com.hz.pm.api.projectlib.model.enumeration;

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

import java.util.Objects;

/**
 *
 * 预警提醒类型枚举
 * @author ZPF
 * @since 2023/10/31 16:14
 */
@Getter
@NoArgsConstructor
@AllArgsConstructor
public enum WarningNoticeTypeEnum {
    /**
     * 预警提醒类型枚举
     */
    CONTACT(1, "项目联系人"),
    RESPONSIBLE(2, "项目负责人");

    private Integer code;
    private String desc;


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

    public static WarningNoticeTypeEnum getByCode(Integer code) {
        if (Objects.isNull(code)) {
            return null;
        }
        for (WarningNoticeTypeEnum t : WarningNoticeTypeEnum.values()) {
            if (code.equals(t.getCode())) {
                return t;
            }
        }
        return null;
    }
}
