增加角色权限不足捕获
This commit is contained in:
@@ -2,6 +2,7 @@ package com.czg.exception;
|
||||
|
||||
import cn.dev33.satoken.exception.NotLoginException;
|
||||
import cn.dev33.satoken.exception.NotPermissionException;
|
||||
import cn.dev33.satoken.exception.NotRoleException;
|
||||
import cn.hutool.core.exceptions.ValidateException;
|
||||
import com.czg.resp.CzgRespCode;
|
||||
import com.czg.resp.CzgResult;
|
||||
@@ -68,6 +69,14 @@ public class CzgControllerAdvice {
|
||||
return CzgResult.failure(CzgRespCode.UN_PERMISSION);
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@ExceptionHandler(value = NotRoleException.class)
|
||||
@ResponseStatus(HttpStatus.OK)
|
||||
public CzgResult<Object> notRoleErrorHandler(NotRoleException ex) {
|
||||
setErrorLog(ex);
|
||||
return CzgResult.failure(CzgRespCode.UN_ROLE);
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@ExceptionHandler(MethodArgumentNotValidException.class)
|
||||
@ResponseStatus(HttpStatus.OK)
|
||||
|
||||
@@ -15,7 +15,8 @@ public enum CzgRespCode {
|
||||
RECORD_EXISTED(602, "记录已存在"),
|
||||
PARAM_ERROR(603, "参数错误"),
|
||||
UNAUTHORIZED(401, "未授权"),
|
||||
UN_PERMISSION(402, "无此接口权限"),;
|
||||
UN_PERMISSION(402, "无此接口权限"),
|
||||
UN_ROLE(403, "角色权限不足");
|
||||
|
||||
private final int code;
|
||||
private final String msg;
|
||||
|
||||
Reference in New Issue
Block a user