Browse Source

全局异常处理

tags/v2.2
RuoYi 4 years ago
parent
commit
4ec6d51aca
  1. 2
      ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/factory/RemoteUserFallbackFactory.java
  2. 6
      ruoyi-auth/src/main/java/com/ruoyi/auth/service/SysLoginService.java
  3. 2
      ruoyi-common/ruoyi-common-security/src/main/java/com/ruoyi/common/security/handler/GlobalExceptionHandler.java

2
ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/factory/RemoteUserFallbackFactory.java

@ -27,7 +27,7 @@ public class RemoteUserFallbackFactory implements FallbackFactory<RemoteUserServ @@ -27,7 +27,7 @@ public class RemoteUserFallbackFactory implements FallbackFactory<RemoteUserServ
@Override
public R<LoginUser> getUserInfo(String username)
{
return null;
return R.fail("获取用户失败:" + throwable.getMessage());
}
};
}

6
ruoyi-auth/src/main/java/com/ruoyi/auth/service/SysLoginService.java

@ -55,6 +55,12 @@ public class SysLoginService @@ -55,6 +55,12 @@ public class SysLoginService
}
// 查询用户信息
R<LoginUser> userResult = remoteUserService.getUserInfo(username);
if (R.FAIL == userResult.getCode())
{
throw new BaseException(userResult.getMsg());
}
if (StringUtils.isNull(userResult) || StringUtils.isNull(userResult.getData()))
{
remoteLogService.saveLogininfor(username, Constants.LOGIN_FAIL, "登录用户不存在");

2
ruoyi-common/ruoyi-common-security/src/main/java/com/ruoyi/common/security/handler/GlobalExceptionHandler.java

@ -29,7 +29,7 @@ public class GlobalExceptionHandler @@ -29,7 +29,7 @@ public class GlobalExceptionHandler
@ExceptionHandler(BaseException.class)
public AjaxResult baseException(BaseException e)
{
return AjaxResult.error(e.getMessage());
return AjaxResult.error(e.getDefaultMessage());
}
/**

Loading…
Cancel
Save