package com.gyee.wisdom.adapter.common.result; /* * #1001~1999 区间表示参数错误 * #2001~2999 区间表示用户错误 * #3001~3999 区间表示权限异常 */ public enum ResultCode { /* 成功 */ SUCCESS(2000, "成功"), /* 默认失败 */ ERROR(4004, "失败"), ERROR_CONNECT(4005, "数据库连接异常"), ERROR_DATA(4006, "数据查询失败"), /* 参数错误:1000~1999 */ PARAM_NOT_VALID(1001, "参数无效"), PARAM_IS_BLANK(1002, "参数为空"), PARAM_TYPE_ERROR(1003, "参数类型错误"), PARAM_NOT_COMPLETE(1004, "参数缺失"), /* 用户错误 */ USER_NOT_LOGIN(2001, "用户未登录"), USER_ACCOUNT_ERROR(2002, "账号或密码错误"), USER_FAIL_LOGIN(2003, "登录失败"), /* 业务错误 */ NO_PERMISSION(3001, "没有权限"); private Integer code; private String message; ResultCode(Integer code) { this.code = code; } ResultCode(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 (ResultCode ele : values()) { if (ele.getCode().equals(code)) { return ele.getMessage(); } } return null; } }