From 120f73549d7898b8239ffc21f3320a8dbad2c2b1 Mon Sep 17 00:00:00 2001 From: Pu Zhibing <393733352@qq.com> Date: 星期六, 26 七月 2025 09:09:58 +0800 Subject: [PATCH] Merge branch 'master' of http://120.76.84.145:10101/gitblit/r/java/QianYunTong --- ManagementQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/core/aop/GlobalExceptionHandler.java | 16 ++++++++++------ 1 files changed, 10 insertions(+), 6 deletions(-) diff --git a/ManagementQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/core/aop/GlobalExceptionHandler.java b/ManagementQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/core/aop/GlobalExceptionHandler.java index 5f4f745..9ea8cc6 100644 --- a/ManagementQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/core/aop/GlobalExceptionHandler.java +++ b/ManagementQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/core/aop/GlobalExceptionHandler.java @@ -1,17 +1,18 @@ package com.stylefeng.guns.core.aop; +import com.stylefeng.guns.core.base.tips.ErrorTip; +import com.stylefeng.guns.core.beetl.ShiroExtUtil; import com.stylefeng.guns.core.common.exception.BizExceptionEnum; import com.stylefeng.guns.core.common.exception.InvalidKaptchaException; -import com.stylefeng.guns.core.base.tips.ErrorTip; import com.stylefeng.guns.core.exception.GunsException; import com.stylefeng.guns.core.log.LogManager; import com.stylefeng.guns.core.log.factory.LogTaskFactory; -import com.stylefeng.guns.core.shiro.ShiroKit; import org.apache.shiro.authc.AuthenticationException; import org.apache.shiro.authc.CredentialsException; import org.apache.shiro.authc.DisabledAccountException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.core.annotation.Order; import org.springframework.http.HttpStatus; import org.springframework.ui.Model; @@ -20,6 +21,7 @@ import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.ResponseStatus; +import javax.annotation.Resource; import java.lang.reflect.UndeclaredThrowableException; import static com.stylefeng.guns.core.support.HttpKit.getIp; @@ -34,9 +36,11 @@ @ControllerAdvice @Order(-1) public class GlobalExceptionHandler { - + private Logger log = LoggerFactory.getLogger(this.getClass()); - + @Autowired + private ShiroExtUtil shiroExtUtil; + /** * 拦截业务异常 */ @@ -44,7 +48,7 @@ @ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR) @ResponseBody public ErrorTip notFount(GunsException e) { - LogManager.me().executeLog(LogTaskFactory.exceptionLog(ShiroKit.getUser().getId(), e)); + LogManager.me().executeLog(LogTaskFactory.exceptionLog(shiroExtUtil.getUser().getId(), e)); getRequest().setAttribute("tip", e.getMessage()); log.error("业务异常:", e); return new ErrorTip(e.getCode(), e.getMessage()); @@ -115,7 +119,7 @@ @ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR) @ResponseBody public ErrorTip notFount(RuntimeException e) { - LogManager.me().executeLog(LogTaskFactory.exceptionLog(ShiroKit.getUser().getId(), e)); + LogManager.me().executeLog(LogTaskFactory.exceptionLog(shiroExtUtil.getUser().getId(), e)); getRequest().setAttribute("tip", "服务器未知运行时异常"); log.error("运行时异常:", e); return new ErrorTip(BizExceptionEnum.SERVER_ERROR.getCode(), BizExceptionEnum.SERVER_ERROR.getMessage()); -- Gitblit v1.7.1