mirror of
https://gitee.com/youlaitech/youlai-mall.git
synced 2024-12-22 12:48:59 +08:00
refactor: 优化线上数据库无权操作权限提示
This commit is contained in:
parent
1d0bc1f41e
commit
7ce3fe8e27
@ -30,7 +30,7 @@ public enum ResultCode implements IResultCode, Serializable {
|
||||
|
||||
AUTHORIZED_ERROR("A0300", "访问权限异常"),
|
||||
ACCESS_UNAUTHORIZED("A0301", "访问未授权"),
|
||||
FORBIDDEN_OPERATION("A0302", "演示环境禁止修改、删除重要数据,请本地部署后测试"),
|
||||
FORBIDDEN_OPERATION("A0302", "演示环境禁止新增、修改和删除重要数据,请本地部署后测试"),
|
||||
|
||||
|
||||
PARAM_ERROR("A0400", "用户请求参数错误"),
|
||||
|
@ -144,9 +144,6 @@ public class GlobalExceptionHandler {
|
||||
return Result.failed(errorMessage);
|
||||
}
|
||||
|
||||
/**
|
||||
* TypeMismatchException
|
||||
*/
|
||||
@ResponseStatus(HttpStatus.BAD_REQUEST)
|
||||
@ExceptionHandler(TypeMismatchException.class)
|
||||
public <T> Result<T> processException(TypeMismatchException e) {
|
||||
@ -160,7 +157,7 @@ public class GlobalExceptionHandler {
|
||||
String errorMsg = e.getMessage();
|
||||
log.error(errorMsg);
|
||||
if (StrUtil.isNotBlank(errorMsg) && errorMsg.contains("denied to user")) {
|
||||
return Result.failed("数据库用户无操作权限,建议本地搭建数据库环境");
|
||||
return Result.failed(ResultCode.FORBIDDEN_OPERATION);
|
||||
} else {
|
||||
return Result.failed(e.getMessage());
|
||||
}
|
||||
@ -195,8 +192,13 @@ public class GlobalExceptionHandler {
|
||||
@ResponseStatus(HttpStatus.BAD_REQUEST)
|
||||
@ExceptionHandler(Exception.class)
|
||||
public <T> Result<T> handleException(Exception e) {
|
||||
log.error("unknown exception:{}", e.getMessage());
|
||||
return Result.failed(e.getMessage());
|
||||
String errorMsg = e.getMessage();
|
||||
if (StrUtil.isNotBlank(errorMsg) && errorMsg.contains("denied to user")) {
|
||||
return Result.failed(ResultCode.FORBIDDEN_OPERATION);
|
||||
}else{
|
||||
log.error("unknown exception:{}", e.getMessage());
|
||||
return Result.failed(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user