NorthLan 7 years ago
parent
commit
968ea99ece

+ 7 - 2
zen-api/src/main/kotlin/com/gxzc/zen/sso/aop/CurrentUserHandler.kt

@@ -2,6 +2,7 @@ package com.gxzc.zen.sso.aop
 
 import com.gxzc.zen.api.util.SysUserUtil
 import com.gxzc.zen.umps.util.SSOUtil
+import org.springframework.web.method.HandlerMethod
 import org.springframework.web.servlet.ModelAndView
 import org.springframework.web.servlet.handler.HandlerInterceptorAdapter
 import javax.servlet.http.HttpServletRequest
@@ -16,12 +17,16 @@ import javax.servlet.http.HttpServletResponse
 class CurrentUserHandler : HandlerInterceptorAdapter() {
 
     override fun preHandle(request: HttpServletRequest?, response: HttpServletResponse?, handler: Any?): Boolean {
-        SSOUtil.TL.set(SysUserUtil.getById(SSOUtil.getCurUserId(request!!)!!)!!)
+        if (handler is HandlerMethod) {
+            SSOUtil.TL.set(SysUserUtil.getById(SSOUtil.getCurUserId(request!!)!!)!!)
+        }
         return super.preHandle(request, response, handler)
     }
 
     override fun postHandle(request: HttpServletRequest?, response: HttpServletResponse?, handler: Any?, modelAndView: ModelAndView?) {
-        SSOUtil.TL.clear()
+        if (handler is HandlerMethod) {
+            SSOUtil.TL.clear()
+        }
         super.postHandle(request, response, handler, modelAndView)
     }
 }