From ed2823ccf96675ab29414a588bba85bb8852ef9d Mon Sep 17 00:00:00 2001
From: 廖井涛 <2265517004@qq.com>
Date: 星期日, 28 四月 2024 11:52:25 +0800
Subject: [PATCH] Merge branch 'master' of https://gitee.com/a1536384743/erp_-override

---
 north-glass-erp/src/main/java/com/example/erp/exception/GlobalExceptionHandle.java |   20 ++++++++++++++++++++
 1 files changed, 20 insertions(+), 0 deletions(-)

diff --git a/north-glass-erp/src/main/java/com/example/erp/exception/GlobalExceptionHandle.java b/north-glass-erp/src/main/java/com/example/erp/exception/GlobalExceptionHandle.java
index e353e73..cc7d89a 100644
--- a/north-glass-erp/src/main/java/com/example/erp/exception/GlobalExceptionHandle.java
+++ b/north-glass-erp/src/main/java/com/example/erp/exception/GlobalExceptionHandle.java
@@ -1,9 +1,15 @@
 package com.example.erp.exception;
 
+import cn.dev33.satoken.exception.NotLoginException;
+import cn.dev33.satoken.exception.NotPermissionException;
+import cn.dev33.satoken.util.SaResult;
+import com.example.erp.common.Constants;
 import com.example.erp.common.Result;
 import org.springframework.web.bind.annotation.ControllerAdvice;
 import org.springframework.web.bind.annotation.ExceptionHandler;
 import org.springframework.web.bind.annotation.ResponseBody;
+
+import java.util.Arrays;
 
 @ControllerAdvice
 public class GlobalExceptionHandle {
@@ -15,4 +21,18 @@
     public Result handle(ServiceException se){
         return Result.error(se.getCode(),se.getMessage());
     }
+
+    @ExceptionHandler(NotPermissionException.class)
+    @ResponseBody
+    public Result handlerException(NotPermissionException e) {
+        return Result.error(Constants.Code_401,e.getPermission());
+    }
+
+    // 鎷︽埅锛氭湭鐧诲綍寮傚父
+    @ExceptionHandler(NotLoginException.class)
+    @ResponseBody
+    public Result handlerException(NotLoginException e) {
+        // 杩斿洖缁欏墠绔�
+        return Result.error(Constants.Code_402,"Please login user");
+    }
 }

--
Gitblit v1.8.0