Commit 60204813 authored by 郭武斌's avatar 郭武斌

*)删除冗余代码

parent 3b7d53fa
package com.yeejoin.amos.boot.module.jcs.biz.aop; //package com.yeejoin.amos.boot.module.jcs.biz.aop;
//
//
import org.aspectj.lang.JoinPoint; //import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.AfterReturning; //import org.aspectj.lang.annotation.AfterReturning;
import org.aspectj.lang.annotation.Aspect; //import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before; //import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut; //import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component; //import org.springframework.stereotype.Component;
import org.springframework.web.context.request.RequestContextHolder; //import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes; //import org.springframework.web.context.request.ServletRequestAttributes;
import org.typroject.tyboot.core.foundation.context.RequestContext; //import org.typroject.tyboot.core.foundation.context.RequestContext;
//
import javax.servlet.http.HttpServletRequest; //import javax.servlet.http.HttpServletRequest;
import java.util.Arrays; //import java.util.Arrays;
//
//
/** ///**
* feign请求header设置 // * feign请求header设置
* @author DELL // * @author DELL
* // *
*/ // */
@Aspect //@Aspect
@Component //@Component
public class FeignAop { //public class FeignAop {
//
//
//
@Pointcut("execution(public * com.yeejoin.amos.boot.module.jcs.biz.service.impl.RemoteSecurityService.*(..))") // @Pointcut("execution(public * com.yeejoin.amos.boot.module.jcs.biz.service.impl.RemoteSecurityService.*(..))")
public void webLog(){} // public void webLog(){}
//
/** // /**
* 前置通知:在连接点之前执行的通知 // * 前置通知:在连接点之前执行的通知
* @param joinPoint // * @param joinPoint
* @throws Throwable // * @throws Throwable
*/ // */
@Before("webLog()") // @Before("webLog()")
public void doBefore(JoinPoint joinPoint) throws Throwable { // public void doBefore(JoinPoint joinPoint) throws Throwable {
// 接收到请求,记录请求内容 // // 接收到请求,记录请求内容
ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes(); // ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
HttpServletRequest request = attributes.getRequest(); // HttpServletRequest request = attributes.getRequest();
//不需要添加请求头的接口 // //不需要添加请求头的接口
String[] url=new String[]{"/api/user/mobile/login"}; // String[] url=new String[]{"/api/user/mobile/login"};
//获取请求路径 // //获取请求路径
if(Arrays.asList(url).contains(request.getRequestURI())){ // if(Arrays.asList(url).contains(request.getRequestURI())){
//暂无需要 // //暂无需要
}else{ // }else{
//
String token = request.getHeader("token"); // String token = request.getHeader("token");
String product = request.getHeader("product"); // String product = request.getHeader("product");
String appKey = request.getHeader("appKey"); // String appKey = request.getHeader("appKey");
if(token==null||product==null||appKey==null||"".equals(token)||"".equals(product)||"".equals(appKey)){ // if(token==null||product==null||appKey==null||"".equals(token)||"".equals(product)||"".equals(appKey)){
//没有请求头信息直接转异常到403 // //没有请求头信息直接转异常到403
throw new RuntimeException("非法异常请求!请重新登录!"); // throw new RuntimeException("非法异常请求!请重新登录!");
} // }
RequestContext.setToken(token); // RequestContext.setToken(token);
RequestContext.setProduct(product); // RequestContext.setProduct(product);
RequestContext.setAppKey(appKey); // RequestContext.setAppKey(appKey);
} // }
//
//
//
} // }
//
@AfterReturning(returning = "ret",pointcut = "webLog()") // @AfterReturning(returning = "ret",pointcut = "webLog()")
public void doAfterReturning(Object ret) throws Throwable { // public void doAfterReturning(Object ret) throws Throwable {
} // }
} //}
//
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