啊鑫
2024-11-17 f31c396c2de2ec6f7ffa8918086502c8c00c4269
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
package com.gs.dingtalk.dto;
 
public enum ApiResponseCode {
    SUCCESS("408", "请求成功", true),
 
    INVALID_SIGNATURE("400", "签名不正确", false),
    TOKEN_EXPIRED("401", "token过期", false),
    USER_NOT_FOUND("402", "用户不存在", false),
    REQUEST_TOO_FREQUENT("403", "请求太频繁", false),
    API_NOT_FOUND("404", "接口不存在", false),
    USER_EXPIRED("405", "用户到期", false),
    USER_DISABLED("406", "用户被禁用", false),
    NO_ACCESS("407", "没有接口访问权限", false),
    PARAMETER_ERROR("409", "参数出错", false),
    APP_ID_NOT_SENT("410", "appId未发送", false),
    BODY_PARAMETER_ERROR("412", "body参数不正确", false),
    CUSTOM_STRING_TOO_LONG("413", "自定义字符串ext太长", false),
    BUSINESS_PARAMETER_ERROR("414", "业务请求参数出错", false),
    BUSINESS_DATA_NOT_FOUND("415", "请求的业务数据不存在", false);
 
    private final String code;
    private final String description;
    private final Boolean flag;
 
    ApiResponseCode(String code, String description, Boolean flag) {
        this.code = code;
        this.description = description;
        this.flag = flag;
    }
 
    public static ApiResponseCode fromCode(String code) {
        for (ApiResponseCode responseCode : values()) {
            if (responseCode.getCode().equals(code)) {
                return responseCode;
            }
        }
        return null; // Or throw an exception if preferred
    }
 
    public String getCode() {
        return code;
    }
 
    public String getDescription() {
        return description;
    }
 
    public Boolean getFlag() {
        return flag;
    }
}