‘liusuyi’
2024-03-12 48af67d016ceca5d8bd598c478b70c54ed099bf0
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
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 "找不到错误码对应的错误描述,请联系管理员";
    }
}