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
79
80
81
82
| package com.walker.web;
|
| /**
| * 响应代码定义。
| * @author 时克英
| * @date 2022-10-26
| */
| public enum ResponseCode {
|
| /**
| * 对后台普通异常,前端仅返回一个提示,而且不会弹出到界面,主要用于接口反馈。
| * @date 2024-01-05
| */
| EXCEPTION(-1, "系统错误"),
|
| /* 成功 */
| SUCCESS(1, "success"),
| ERROR(0, "error"),
| RE_LOGIN(10, "需要重新登录"),
| TOKEN_ACQUIRED(19, "token_is_acquired"),
| TOKEN_REFRESH(20, "token_need_refresh"),
|
| /* 参数错误:1000~1999 */
| PARAM_NOT_VALID(1001, "参数无效"),
| PARAM_IS_BLANK(1002, "参数为空"),
| PARAM_TYPE_ERROR(1003, "参数类型错误"),
| PARAM_NOT_COMPLETE(1004, "参数缺失"),
|
| /* 用户错误 */
| USER_NOT_LOGIN(2001, "用户未登录"),
| USER_ACCOUNT_EXPIRED(2002, "账号已过期"),
| USER_CREDENTIALS_ERROR(2003, "用户名或密码错误"),
| USER_CREDENTIALS_EXPIRED(2004, "密码过期"),
| USER_ACCOUNT_DISABLE(2005, "账号不可用"),
| USER_ACCOUNT_LOCKED(2006, "账号被锁定"),
| USER_ACCOUNT_NOT_EXIST(2007, "账号不存在"),
| USER_ACCOUNT_ALREADY_EXIST(2008, "账号已存在"),
| USER_ACCOUNT_USE_BY_OTHERS(2009, "账号下线"),
|
| /* 业务错误 */
| NO_PERMISSION(3001, "权限未分配"),
| NO_AUTHENTICATION(401, "未认证,没有权限");
|
| private Integer code;
| private String message;
|
| ResponseCode(Integer code, String message) {
| this.code = code;
| this.message = message;
| }
|
| public Integer getCode() {
| return code;
| }
|
| public void setCode(Integer code) {
| this.code = code;
| }
|
| public String getMessage() {
| return message;
| }
|
| public void setMessage(String message) {
| this.message = message;
| }
|
| /**
| * 根据code获取message
| *
| * @param code
| * @return
| */
| public static String getMessageByCode(Integer code) {
| for (ResponseCode ele : values()) {
| if (ele.getCode().equals(code)) {
| return ele.getMessage();
| }
| }
| return null;
| }
| }
|
|