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_SEND_ERROR(8, "向设备发送失败"),
|
NET_DVR_NETWORK_RECV_TIMEOUT(10, "从设备接收数据超时"),
|
NET_DVR_NETWORK_ERRORDATA(11, "传送的数据有误。发送给设备或者从设备接收到的数据错误,如远程参数配置时输入设备不支持的值"),
|
NET_DVR_DVROPRATEFAILED(29, "设备操作失败"),
|
NET_DVR_USERNOTEXIST(47, "用户不存在。注册的用户ID已注销或不可用");
|
/**
|
* 枚举码
|
*/
|
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 "找不到错误码对应的错误描述,请联系管理员";
|
}
|
}
|