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
| package cn.zou.satokenjwt.result;
public enum CommonResultEnum {
USER_NOT_EXIST_ERROR(512, "用户不存在"), PASSWORD_ERROR(511, "用户密码错误"),
SUCCESS(200, "请求成功"), REGISTER_SUCCESS(200, "注册成功"), ONT_TOKEN(403, "未读取有效token"),
USER_OR_PASSWORD_ERROR(511, "用户或者密码失败"), USER_EXIT_ERROR(513, "用户已存在"), LOGIN_ERROR(511, "用户密码错误"), COMMON_ERROR_MISSING_REQUIRED_PARAMETER(501, "缺少必传参数"), COMMON_EXCEPTION(500, "服务器错误"), ACCESS_DENIED(403, "菜单权限不够"), ROLE_DENIED(403, "角色权限不够"), AUTHENTICATION_FAILED(401, "用户名或者密码错误"), TOKEN_INVALID(401, "token无效"); private final CommonResult<?> result;
CommonResultEnum(int code, String msg) { result = new CommonResult<>(code, msg); }
public <T> CommonResult<T> getResult() { return (CommonResult<T>) result; }
public <T> CommonResult<T> setData(T data) { CommonResult<T> commonResult = new CommonResult<>(result.getCode(), result.getMsg()); commonResult.setData(data); return commonResult; }
public <T> CommonResult<T> setMsg(String msg) { return new CommonResult<>(result.getCode(), result.getMsg()); }
}
|