Commit 04afcfa1 by 陶光胜

Merge branch 'developer' of…

Merge branch 'developer' of http://115.159.76.241/base_platform_enterprise/gic-enterprise-base into developer
parents 376588d2 98d62223
package com.gic.enterprise.ano;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
*
* @ClassName: IgnoreAuth
* @Description: 忽略登录认证的请求
* @author xugh
* @date 2018年5月28日 下午1:45:56
*
*/
@Target({ElementType.METHOD})
@Retention(RetentionPolicy.RUNTIME)
public @interface IgnoreLogin {
}
package com.gic.enterprise.interceptor;
import com.alibaba.fastjson.JSON;
import com.gic.enterprise.ano.IgnoreLogin;
import com.gic.enterprise.base.UserInfo;
import com.gic.enterprise.constants.Constants;
import com.gic.enterprise.context.UserContext;
......@@ -12,6 +13,7 @@ import org.apache.commons.lang.StringUtils;
import org.apache.dubbo.rpc.RpcContext;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.web.method.HandlerMethod;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
......@@ -45,9 +47,19 @@ public class AuthInterceptor extends HandlerInterceptorAdapter {
RpcContext.getContext().getAttachments().put(Constants.USER_TOKEN, token);
System.out.println(JSON.toJSONString(RpcContext.getContext().getArguments()));
if (!(object.getClass().isAssignableFrom(HandlerMethod.class))) {
return true;
}
HandlerMethod handler = (HandlerMethod) object;
IgnoreLogin ignoreLogin = handler.getMethodAnnotation(IgnoreLogin.class);
if (null != ignoreLogin) {
return true;
}
//获取uri
String uri = request.getRequestURI();
String isControl = request.getParameter("isControl");
String isControl = request.getHeader("isControl");
log.info("用户接口访问标志:{}", isControl);
log.info("用户接口访问路由:{}", uri);
//不需要拦截的路径
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment