package com.ruoyi.utils.sdk.common;
|
|
|
import com.ruoyi.common.utils.StringUtils;
|
|
/**
|
* sdk错误码枚举
|
* 刘苏义
|
* 2024/3/7 10:50:52
|
*/
|
public enum SdkErrorCodeEnum {
|
|
NET_DVR_PASSWORD_ERROR(1, "用户名密码错误。注册时输入的用户名或者密码错误"),
|
NET_DVR_NOINIT(3, "SDK未初始化"),
|
NET_DVR_NETWORK_FAIL_CONNECT(7, "连接设备失败。设备不在线或网络原因引起的连接超时等"),
|
NET_DVR_NETWORK_RECV_TIMEOUT(10, "从设备接收数据超时");
|
/**
|
* 枚举码
|
*/
|
private Integer code;
|
/**
|
* 枚举描述
|
*/
|
private String desc;
|
|
private SdkErrorCodeEnum(Integer code, String desc) {
|
this.code = code;
|
this.desc = desc;
|
}
|
|
public Integer getCode() {
|
return code;
|
}
|
|
public String getDesc() {
|
return desc;
|
}
|
|
/**
|
* 根据枚举码获取枚举
|
*
|
* @param code 枚举码
|
* @return 枚举
|
*/
|
public static final SdkErrorCodeEnum getByCode(Integer code) {
|
if (StringUtils.isNull(code)) {
|
return null;
|
}
|
for (SdkErrorCodeEnum item : SdkErrorCodeEnum.values()) {
|
if (item.getCode() == code) {
|
return item;
|
}
|
}
|
return null;
|
}
|
|
/**
|
* 根据枚举码获取枚举描述
|
*
|
* @param code 枚举码
|
* @return 枚举描述
|
*/
|
public static final String getDescByCode(Integer code) {
|
if (StringUtils.isNull(code)) {
|
return "错误码为空";
|
}
|
for (SdkErrorCodeEnum item : SdkErrorCodeEnum.values()) {
|
if (item.getCode() == code) {
|
return item.getDesc();
|
}
|
}
|
return "找不到错误码对应的错误描述,请联系管理员";
|
}
|
}
|