SysWarningLevelEnums.java 1.1 KB
package com.skua.modules.util;

import lombok.Getter;

/**
 * 系统告警级别
 */
@Getter
public enum SysWarningLevelEnums {

	WARNING_LEVEL_1("重要报警",30),
	WARNING_LEVEL_2("一般报警",20),
	WARNING_LEVEL_3("提醒报警",10);


	;

	private String value;
	//等级(值越大,等级越高)
	private Integer level;

	SysWarningLevelEnums(String value, Integer level) {
		this.value = value;
		this.level = level;
	}


	/**
	 * 校验【告警级别】是否合法,不合法则返回'提醒告警'
	 * @param warningLevel
	 * @return
	 */
	public static String verifyLevel(String warningLevel){
		for (SysWarningLevelEnums e : SysWarningLevelEnums.values()) {
			if(e.getValue().equals(warningLevel)){
				return e.getValue();
			}
		}

		return WARNING_LEVEL_3.getValue();
	}

	/**
	 *
	 * @param warningLevel 告警等级
	 * @return
	 */
	public static SysWarningLevelEnums getByLevel(String warningLevel){
		for (SysWarningLevelEnums e : SysWarningLevelEnums.values()) {
			if(e.getValue().equals(warningLevel)){
				return e;
			}
		}

		return WARNING_LEVEL_3;
	}

}