feat(auth): 新增用户权限管理模块
- 新增权限、角色、用户角色关联等数据对象及Mapper - 实现权限数据同步至Redis的功能 - 新增用户登录与注册接口,支持验证码登录 - 完善全局异常处理,增加对Guava参数校验异常的捕获 - 修改用户DO字段类型,使用LocalDate与LocalDateTime替代Date - 新增删除状态枚举类DeletedEnum和状态枚举类StatusEnum - 调整响应码结构,区分邮件相关错误码 - 新增RedisKeyConstants中关于用户角色与角色权限的KEY构建方法 - 新增RoleConstants定义普通用户角色ID常量
This commit is contained in:
@@ -13,6 +13,7 @@ import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
@SuppressWarnings("LoggingSimilarMessage")
|
||||
@ControllerAdvice
|
||||
@Slf4j
|
||||
public class GlobalExceptionHandler {
|
||||
@@ -66,11 +67,30 @@ public class GlobalExceptionHandler {
|
||||
return Response.fail(errorCode, errorMessage);
|
||||
}
|
||||
|
||||
/**
|
||||
* 捕获 guava 参数校验异常
|
||||
*
|
||||
* @return Response.fail(ResponseCodeEnum.PARAM_NOT_VALID)
|
||||
*/
|
||||
@ExceptionHandler({IllegalArgumentException.class})
|
||||
@ResponseBody
|
||||
public Response<Object> handleIllegalArgumentException(HttpServletRequest request, IllegalArgumentException e) {
|
||||
// 参数错误异常码
|
||||
String errorCode = ResponseCodeEnum.PARAM_NOT_VALID.getErrorCode();
|
||||
|
||||
// 错误信息
|
||||
String errorMessage = e.getMessage();
|
||||
|
||||
log.warn("{} request error, errorCode: {}, errorMessage: {}", request.getRequestURI(), errorCode, errorMessage);
|
||||
|
||||
return Response.fail(errorCode, errorMessage);
|
||||
}
|
||||
|
||||
/**
|
||||
* 其他类型异常
|
||||
*
|
||||
* @param request 请求
|
||||
* @param e 异常
|
||||
* @param e 异常
|
||||
* @return Response.fail(ResponseCodeEnum.SYSTEM_ERROR)
|
||||
*/
|
||||
@ExceptionHandler({Exception.class})
|
||||
|
||||
Reference in New Issue
Block a user