‘liusuyi’
2024-04-18 b81192f7fc3c8050b17e68689062654c15a73ef9
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
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 "找不到错误码对应的错误描述,请联系管理员";
    }
}