|
|
|
|
@@ -17,6 +17,7 @@ import org.wfc.common.core.exception.ServiceException;
|
|
|
|
|
import org.wfc.common.core.exception.auth.NotPermissionException;
|
|
|
|
|
import org.wfc.common.core.exception.auth.NotRoleException;
|
|
|
|
|
import org.wfc.common.core.text.Convert;
|
|
|
|
|
import org.wfc.common.core.utils.MessageUtils;
|
|
|
|
|
import org.wfc.common.core.utils.StringUtils;
|
|
|
|
|
import org.wfc.common.core.utils.html.EscapeUtil;
|
|
|
|
|
import org.wfc.common.core.web.domain.AjaxResult;
|
|
|
|
|
@@ -38,8 +39,8 @@ public class GlobalExceptionHandler
|
|
|
|
|
public AjaxResult handleNotPermissionException(NotPermissionException e, HttpServletRequest request)
|
|
|
|
|
{
|
|
|
|
|
String requestURI = request.getRequestURI();
|
|
|
|
|
log.error("请求地址'{}',权限码校验失败'{}'", requestURI, e.getMessage());
|
|
|
|
|
return AjaxResult.error(HttpStatus.FORBIDDEN, "没有访问权限,请联系管理员授权");
|
|
|
|
|
log.error("Request address'{}',Permission code verification failed'{}'", requestURI, e.getMessage());
|
|
|
|
|
return AjaxResult.error(HttpStatus.FORBIDDEN, "common.no.permission");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@@ -49,8 +50,8 @@ public class GlobalExceptionHandler
|
|
|
|
|
public AjaxResult handleNotRoleException(NotRoleException e, HttpServletRequest request)
|
|
|
|
|
{
|
|
|
|
|
String requestURI = request.getRequestURI();
|
|
|
|
|
log.error("请求地址'{}',角色权限校验失败'{}'", requestURI, e.getMessage());
|
|
|
|
|
return AjaxResult.error(HttpStatus.FORBIDDEN, "没有访问权限,请联系管理员授权");
|
|
|
|
|
log.error("Request address'{}',Role permission verification failed'{}'", requestURI, e.getMessage());
|
|
|
|
|
return AjaxResult.error(HttpStatus.FORBIDDEN, "common.no.permission");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@@ -60,7 +61,7 @@ public class GlobalExceptionHandler
|
|
|
|
|
public AjaxResult handleHttpRequestMethodNotSupported(HttpRequestMethodNotSupportedException e, HttpServletRequest request)
|
|
|
|
|
{
|
|
|
|
|
String requestURI = request.getRequestURI();
|
|
|
|
|
log.error("请求地址'{}',不支持'{}'请求", requestURI, e.getMethod());
|
|
|
|
|
log.error("Request address'{}','{}' request not supported", requestURI, e.getMethod());
|
|
|
|
|
return AjaxResult.error(e.getMessage());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -82,8 +83,8 @@ public class GlobalExceptionHandler
|
|
|
|
|
public AjaxResult handleMissingPathVariableException(MissingPathVariableException e, HttpServletRequest request)
|
|
|
|
|
{
|
|
|
|
|
String requestURI = request.getRequestURI();
|
|
|
|
|
log.error("请求路径中缺少必需的路径变量'{}',发生系统异常.", requestURI, e);
|
|
|
|
|
return AjaxResult.error(String.format("请求路径中缺少必需的路径变量[%s]", e.getVariableName()));
|
|
|
|
|
log.error("The required path variable '{}' is missing from the request path, and a system exception occurred.", requestURI, e);
|
|
|
|
|
return AjaxResult.error(MessageUtils.message("common.request.path.variable.not.blank", e.getVariableName()));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@@ -98,8 +99,8 @@ public class GlobalExceptionHandler
|
|
|
|
|
{
|
|
|
|
|
value = EscapeUtil.clean(value);
|
|
|
|
|
}
|
|
|
|
|
log.error("请求参数类型不匹配'{}',发生系统异常.", requestURI, e);
|
|
|
|
|
return AjaxResult.error(String.format("请求参数类型不匹配,参数[%s]要求类型为:'%s',但输入值为:'%s'", e.getName(), e.getRequiredType().getName(), value));
|
|
|
|
|
log.error("The request parameter type does not match '{}', and a system exception occurred.", requestURI, e);
|
|
|
|
|
return AjaxResult.error(MessageUtils.message("common.request.parameter.type.not.match", e.getName(), e.getRequiredType().getName(), value));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@@ -109,7 +110,7 @@ public class GlobalExceptionHandler
|
|
|
|
|
public AjaxResult handleRuntimeException(RuntimeException e, HttpServletRequest request)
|
|
|
|
|
{
|
|
|
|
|
String requestURI = request.getRequestURI();
|
|
|
|
|
log.error("请求地址'{}',发生未知异常.", requestURI, e);
|
|
|
|
|
log.error("Requesting address '{}', an unknown exception occurred.", requestURI, e);
|
|
|
|
|
return AjaxResult.error(e.getMessage());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -120,7 +121,7 @@ public class GlobalExceptionHandler
|
|
|
|
|
public AjaxResult handleException(Exception e, HttpServletRequest request)
|
|
|
|
|
{
|
|
|
|
|
String requestURI = request.getRequestURI();
|
|
|
|
|
log.error("请求地址'{}',发生系统异常.", requestURI, e);
|
|
|
|
|
log.error("Requesting address '{}', an unknown exception occurred.", requestURI, e);
|
|
|
|
|
return AjaxResult.error(e.getMessage());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -161,6 +162,6 @@ public class GlobalExceptionHandler
|
|
|
|
|
@ExceptionHandler(DemoModeException.class)
|
|
|
|
|
public AjaxResult handleDemoModeException(DemoModeException e)
|
|
|
|
|
{
|
|
|
|
|
return AjaxResult.error("演示模式,不允许操作");
|
|
|
|
|
return AjaxResult.error("common.demo.mode");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|