增加用户登录超时异常

This commit is contained in:
ajaxfan
2021-05-06 15:06:19 +08:00
parent c63b0dfb01
commit f24554dc41
2 changed files with 48 additions and 43 deletions

View File

@ -6,6 +6,7 @@ import lombok.Getter;
/** /**
* 公共错误提示信息 * 公共错误提示信息
*
* @author daixc * @author daixc
* @date 2020/10/10 * @date 2020/10/10
*/ */
@ -13,47 +14,50 @@ import lombok.Getter;
@AllArgsConstructor @AllArgsConstructor
public enum CommonExceptionEnum implements BusinessExceptionAssert { public enum CommonExceptionEnum implements BusinessExceptionAssert {
/** /**
* 数据为空 * 数据为空
*/ */
FRAME_EXCEPTION_COMMON_NOT_FIND(100001, "数据为空!"), FRAME_EXCEPTION_COMMON_NOT_FIND(100001, "数据为空!"),
/** /**
* 数据不存在 * 数据不存在
*/ */
FRAME_EXCEPTION_COMMON_NOT_EXIST(100002, "数据不存在!"), FRAME_EXCEPTION_COMMON_NOT_EXIST(100002, "数据不存在!"),
/** /**
* 数据修改失败 * 数据修改失败
*/ */
FRAME_EXCEPTION_COMMON_NOT_UPDATE(100003,"数据修改失败,请刷新后重试!"), FRAME_EXCEPTION_COMMON_NOT_UPDATE(100003, "数据修改失败,请刷新后重试!"),
/** /**
* id为空 * id为空
*/ */
FRAME_EXCEPTION_COMMON_ID_IS_NULL(100004, "id为空"), FRAME_EXCEPTION_COMMON_ID_IS_NULL(100004, "id为空"),
/** /**
* 数据已存在 * 数据已存在
*/ */
FRAME_EXCEPTION_COMMON_REPEAT(100005, "数据已存在"), FRAME_EXCEPTION_COMMON_REPEAT(100005, "数据已存在"),
/** /**
* 数据已存在 * 数据已存在
*/ */
FRAME_EXCEPTION_COMMON_ID_FORMAT(100006, "id格式错误"), FRAME_EXCEPTION_COMMON_ID_FORMAT(100006, "id格式错误"),
/** /**
* 数据错误 * 数据错误
*/ */
FRAME_EXCEPTION_COMMON_DATA__ERROR(100007, "数据错误"), FRAME_EXCEPTION_COMMON_DATA__ERROR(100007, "数据错误"),
/** /**
* 自定义输出内容 * 自定义输出内容
*/ */
FRAME_EXCEPTION_COMMON_DATA_OTHER_ERROR(100999, ""); FRAME_EXCEPTION_COMMON_DATA_OTHER_ERROR(100999, ""),
/**
* 登陆已超期
*/
LOGIN_EXPIRATION(90401, "登陆已超期");
/**
/** * 返回码
* 返回码 */
*/ private int code;
private int code; /**
/** * 返回消息
* 返回消息 */
*/ private String message;
private String message;
} }

View File

@ -28,6 +28,7 @@ import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.method.annotation.MethodArgumentTypeMismatchException; import org.springframework.web.method.annotation.MethodArgumentTypeMismatchException;
import com.chinaunicom.mall.ebtp.common.base.entity.BaseResponse; import com.chinaunicom.mall.ebtp.common.base.entity.BaseResponse;
import com.chinaunicom.mall.ebtp.common.exception.common.CommonExceptionEnum;
import com.chinaunicom.mall.ebtp.common.exception.entity.AuthFailureException; import com.chinaunicom.mall.ebtp.common.exception.entity.AuthFailureException;
import com.chinaunicom.mall.ebtp.common.exception.entity.BusinessException; import com.chinaunicom.mall.ebtp.common.exception.entity.BusinessException;
import com.chinaunicom.mall.ebtp.common.util.JsonUtils; import com.chinaunicom.mall.ebtp.common.util.JsonUtils;
@ -159,8 +160,8 @@ public class BusinessExceptionHandlerAdvice {
Map<String, Object> body = new HashMap<>(); Map<String, Object> body = new HashMap<>();
body.put("errors", exception.getMessage()); body.put("errors", exception.getMessage());
body.put("error", HttpStatus.UNAUTHORIZED.getReasonPhrase()); body.put("error", HttpStatus.UNAUTHORIZED.getReasonPhrase());
// body.put("path", request.getRequestURI());
return BaseResponse.fail(HttpStatus.UNAUTHORIZED.value(), "登陆已超期", Convert.toStr(body)); return BaseResponse.fail(CommonExceptionEnum.LOGIN_EXPIRATION.getCode(), "登陆已超期", Convert.toStr(body));
} }
/** /**