|  | @@ -11,6 +11,8 @@ import javax.servlet.http.HttpServletResponse;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  import com.alibaba.fastjson.JSONObject;
 | 
	
		
			
				|  |  |  import org.apache.commons.lang3.StringUtils;
 | 
	
		
			
				|  |  | +import org.springframework.beans.factory.annotation.Autowired;
 | 
	
		
			
				|  |  | +import org.springframework.context.annotation.Lazy;
 | 
	
		
			
				|  |  |  import org.springframework.web.method.HandlerMethod;
 | 
	
		
			
				|  |  |  import org.springframework.web.servlet.HandlerInterceptor;
 | 
	
		
			
				|  |  |  import org.springframework.web.servlet.ModelAndView;
 | 
	
	
		
			
				|  | @@ -40,13 +42,17 @@ public class TokenInterceptorHandler implements HandlerInterceptor {
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      private String key;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +    @Autowired
 | 
	
		
			
				|  |  | +    @Lazy
 | 
	
		
			
				|  |  | +    GoTokenAuthentication goTokenAuthentication;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |      /**
 | 
	
		
			
				|  |  |       * Controller执行之前,如果返回false,controller不执行
 | 
	
		
			
				|  |  |       *
 | 
	
		
			
				|  |  |       * @throws Exception
 | 
	
		
			
				|  |  |       */
 | 
	
		
			
				|  |  |      @Override
 | 
	
		
			
				|  |  | -    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
 | 
	
		
			
				|  |  | +    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception{
 | 
	
		
			
				|  |  |          log.debug("preHandle ......");
 | 
	
		
			
				|  |  |          // 获取配置
 | 
	
		
			
				|  |  |          TokenProperties properties = SpringHelper.getBean(TokenProperties.class);
 | 
	
	
		
			
				|  | @@ -71,9 +77,10 @@ public class TokenInterceptorHandler implements HandlerInterceptor {
 | 
	
		
			
				|  |  |                                  throw new RunException(RunExc.TOKEN, "请重新登录");
 | 
	
		
			
				|  |  |                              }
 | 
	
		
			
				|  |  |                          }
 | 
	
		
			
				|  |  | +                        Claims claims = null;
 | 
	
		
			
				|  |  |                          try {
 | 
	
		
			
				|  |  |                              // 获取token
 | 
	
		
			
				|  |  | -                            Claims claims = JwtHelper.parser(token);
 | 
	
		
			
				|  |  | +                            claims = JwtHelper.parser(token);
 | 
	
		
			
				|  |  |                              // 设置request
 | 
	
		
			
				|  |  |                              request.setAttribute(TokenCfg.USERID, claims.getOrDefault(TokenCfg.USERID, ""));
 | 
	
		
			
				|  |  |                              request.setAttribute(TokenCfg.USERNAME, claims.getOrDefault(TokenCfg.USERNAME, ""));
 | 
	
	
		
			
				|  | @@ -87,6 +94,12 @@ public class TokenInterceptorHandler implements HandlerInterceptor {
 | 
	
		
			
				|  |  |                                  throw new RunException(RunExc.TOKEN);
 | 
	
		
			
				|  |  |                              }
 | 
	
		
			
				|  |  |                          }
 | 
	
		
			
				|  |  | +                        //是否需要验证Permissions
 | 
	
		
			
				|  |  | +                        GoToken goToken = (GoToken)annotation2;
 | 
	
		
			
				|  |  | +                        if(StringUtils.isNotEmpty(goToken.permissions())){
 | 
	
		
			
				|  |  | +                            Long userId = Long.parseLong(claims.getOrDefault(TokenCfg.USERID, "").toString());
 | 
	
		
			
				|  |  | +                            goTokenAuthentication.authenticate(userId, goToken.permissions());
 | 
	
		
			
				|  |  | +                        }
 | 
	
		
			
				|  |  |                      }
 | 
	
		
			
				|  |  |                  }
 | 
	
		
			
				|  |  |              }
 | 
	
	
		
			
				|  | @@ -134,4 +147,5 @@ public class TokenInterceptorHandler implements HandlerInterceptor {
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |          return param;
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |  }
 |