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 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315
| public enum ResponseCodeEnum implements ResponseCodeInterface {
SUCCESS(0, "Success", "COMMON.SUCCESS"), PENDING(1, "In-progress", "COMMON.PENDING"), FAILED(99999, "Failed", "COMMON.FAILED");
private final int code; private final String message; private final String i18nKey;
ResponseCodeEnum(int code, String message, String i18nKey) { this.code = code; this.message = message; this.i18nKey = i18nKey; }
@Override public int code() { return this.code; }
@Override public String message() { return this.message; }
@Override public String i18nKey() { return this.i18nKey; }
public enum Business implements ResponseCodeInterface {
COMMON_OBJECT_NOT_FOUND(10001, "找不到ID为 {} 的 {}", "Business.OBJECT_NOT_FOUND"),
COMMON_UNSUPPORTED_OPERATION(10002, "不支持的操作", "Business.UNSUPPORTED_OPERATION"),
COMMON_FILE_NOT_ALLOWED_TO_DOWNLOAD(10003, "文件名称({})非法,不允许下载", "Business.FILE_NOT_ALLOWED_TO_DOWNLOAD"),
PERMISSION_FORBIDDEN_TO_MODIFY_ADMIN(10101, "不允许修改管理员的信息", "Business.FORBIDDEN_TO_MODIFY_ADMIN"),
PERMISSION_NOT_ALLOWED_TO_OPERATE(10202, "没有权限进行此操作,请联系管理员", "Business.NO_PERMISSION_TO_OPERATE"),
LOGIN_WRONG_USER_PASSWORD(10201, "用户密码错误,请重新输入", "Business.LOGIN_WRONG_USER_PASSWORD"),
LOGIN_ERROR(10202, "登录失败:{}", "Business.LOGIN_ERROR"),
LOGIN_CAPTCHA_CODE_WRONG(10203, "验证码错误", "Business.LOGIN_CAPTCHA_CODE_WRONG"),
LOGIN_CAPTCHA_CODE_EXPIRE(10204, "验证码过期", "Business.LOGIN_CAPTCHA_CODE_EXPIRE"),
LOGIN_CAPTCHA_CODE_NULL(10205, "验证码为空", "Business.LOGIN_CAPTCHA_CODE_NULL"),
UPLOAD_FILE_TYPE_NOT_ALLOWED(10401, "不允许上传的文件类型,仅允许:{}", "Business.UPLOAD_FILE_TYPE_NOT_ALLOWED"),
UPLOAD_FILE_NAME_EXCEED_MAX_LENGTH(10402, "文件名长度超过:{} ", "Business.UPLOAD_FILE_NAME_EXCEED_MAX_LENGTH"),
UPLOAD_FILE_SIZE_EXCEED_MAX_SIZE(10403, "文件名大小超过:{} MB", "Business.UPLOAD_FILE_SIZE_EXCEED_MAX_SIZE"),
UPLOAD_IMPORT_EXCEL_FAILED(10404, "导入excel失败:{}", "Business.UPLOAD_IMPORT_EXCEL_FAILED"),
UPLOAD_FILE_IS_EMPTY(10405, "上传文件为空", "Business.UPLOAD_FILE_IS_EMPTY"),
UPLOAD_FILE_FAILED(10406, "上传文件失败:{}", "Business.UPLOAD_FILE_FAILED"),
USER_NON_EXIST(10501, "登录用户:{} 不存在", "Business.USER_NON_EXIST"),
;
private final int code; private final String message; private final String i18nKey;
Business(int code, String message, String i18nKey) { Assert.isTrue(code > 10000 && code < 99999, "错误码code值定义失败,Business错误码code值范围在10000~99099之间,请查看ErrorCode.Business类,当前错误码码为" + name());
String errorTypeName = this.getClass().getSimpleName(); Assert.isTrue(i18nKey != null && i18nKey.startsWith(errorTypeName), String.format("错误码i18nKey值定义失败,%s错误码i18nKey值必须以%s开头,当前错误码为%s", errorTypeName, errorTypeName, name())); this.code = code; this.message = message; this.i18nKey = i18nKey; }
@Override public int code() { return this.code; }
@Override public String message() { return this.message; }
@Override public String i18nKey() { return i18nKey; } }
public enum External implements ResponseCodeInterface {
FAIL_TO_PAY_ON_ALIPAY(1001, "支付宝调用失败", "External.FAIL_TO_PAY_ON_ALIPAY");
private final int code; private final String message;
private final String i18nKey;
External(int code, String message, String i18nKey) { Assert.isTrue(code > 1000 && code < 9999, "错误码code值定义失败,External错误码code值范围在1000~9999之间,请查看ErrorCode.External类,当前错误码码为" + name());
String errorTypeName = this.getClass().getSimpleName(); Assert.isTrue(i18nKey != null && i18nKey.startsWith(errorTypeName), String.format("错误码i18nKey值定义失败,%s错误码i18nKey值必须以%s开头,当前错误码为%s", errorTypeName, errorTypeName, name())); this.code = code; this.message = message; this.i18nKey = i18nKey; }
@Override public int code() { return this.code; }
@Override public String message() { return this.message; }
@Override public String i18nKey() { return this.i18nKey; }
}
public enum Client implements ResponseCodeInterface {
COMMON_FORBIDDEN_TO_CALL(101, "禁止调用", "Client.COMMON_FORBIDDEN_TO_CALL"),
COMMON_REQUEST_TOO_OFTEN(102, "调用太过频繁", "Client.COMMON_REQUEST_TOO_OFTEN"),
COMMON_REQUEST_PARAMETERS_INVALID(103, "请求参数异常,{0}", "Client.COMMON_REQUEST_PARAMETERS_INVALID"),
COMMON_REQUEST_METHOD_INVALID(104, "请求方式: {} 不支持", "Client.COMMON_REQUEST_METHOD_INVALID"),
COMMON_HTTP_MEDIA_TYPE_NOT_SUPPORTED_ERROR(109, "请求类型:{} 不支持", "Client.COMMON_HTTP_MEDIA_TYPE_NOT_SUPPORTED_ERROR"),
COMMON_REQUEST_RESUBMIT(105, "请求重复提交", "Client.COMMON_REQUEST_RESUBMIT"),
COMMON_NO_AUTHORIZATION(106, "请求接口:{} 失败,用户未授权", "Client.COMMON_NO_AUTHORIZATION"),
INVALID_TOKEN(107, "token异常", "Client.INVALID_TOKEN"),
TOKEN_PROCESS_FAILED(108, "token处理失败:{}", "Client.TOKEN_PROCESS_FAILED"),
;
private final int code; private final String message; private final String i18nKey;
Client(int code, String message, String i18nKey) { Assert.isTrue(code > 100 && code < 999, "错误码code值定义失败,Client错误码code值范围在100~999之间,请查看ErrorCode.Client类,当前错误码码为" + name());
String errorTypeName = this.getClass().getSimpleName(); Assert.isTrue(i18nKey != null && i18nKey.startsWith(errorTypeName), String.format("错误码i18nKey值定义失败,%s错误码i18nKey值必须以%s开头,当前错误码为%s", errorTypeName, errorTypeName, name())); this.code = code; this.message = message; this.i18nKey = i18nKey; }
@Override public int code() { return this.code; }
@Override public String message() { return this.message; }
@Override public String i18nKey() { return this.i18nKey; }
}
public enum Internal implements ResponseCodeInterface {
INVALID_PARAMETER(1, "参数异常:{}", "Internal.INVALID_PARAMETER"),
INTERNAL_ERROR(2, "系统内部错误:{}", "Internal.INTERNAL_ERROR"),
GET_ENUM_FAILED(3, "获取枚举类型失败, 枚举类:{}", "Internal.GET_ENUM_FAILED"),
GET_CACHE_FAILED(4, "获取缓存失败", "Internal.GET_CACHE_FAILED"),
DB_INTERNAL_ERROR(5, "数据库异常", "Internal.DB_INTERNAL_ERROR"),
LOGIN_CAPTCHA_GENERATE_FAIL(7, "验证码生成失败", "Internal.LOGIN_CAPTCHA_GENERATE_FAIL"),
EXCEL_PROCESS_ERROR(8, "excel处理失败:{}", "Internal.EXCEL_PROCESS_ERROR"),
;
private final int code; private final String message;
private final String i18nKey;
Internal(int code, String message, String i18nKey) { Assert.isTrue(code < 100, "错误码code值定义失败,Internal错误码code值范围在100~999之间,请查看ErrorCode.Internal类,当前错误码码为" + name());
String errorTypeName = this.getClass().getSimpleName(); Assert.isTrue(i18nKey != null && i18nKey.startsWith(errorTypeName), String.format("错误码i18nKey值定义失败,%s错误码i18nKey值必须以%s开头,当前错误码为%s", errorTypeName, errorTypeName, name())); this.code = code; this.message = message; this.i18nKey = i18nKey; }
@Override public int code() { return this.code; }
@Override public String message() { return this.message; }
@Override public String i18nKey() { return this.i18nKey; }
}
}
|