|  | @ -0,0 +1,37 @@
 | 
	
		
			
				|  |  | package com.yihu.jw.base.aop;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | import org.aspectj.lang.ProceedingJoinPoint;
 | 
	
		
			
				|  |  | import org.aspectj.lang.annotation.Around;
 | 
	
		
			
				|  |  | import org.aspectj.lang.annotation.Aspect;
 | 
	
		
			
				|  |  | import org.aspectj.lang.reflect.MethodSignature;
 | 
	
		
			
				|  |  | import org.springframework.core.annotation.Order;
 | 
	
		
			
				|  |  | import org.springframework.stereotype.Component;
 | 
	
		
			
				|  |  | import org.springframework.web.context.request.RequestContextHolder;
 | 
	
		
			
				|  |  | import org.springframework.web.context.request.ServletRequestAttributes;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | import java.lang.reflect.Method;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | /**
 | 
	
		
			
				|  |  |  * Created by wsy on 2021/9/7.
 | 
	
		
			
				|  |  |  */
 | 
	
		
			
				|  |  | @Order(5)
 | 
	
		
			
				|  |  | @Aspect
 | 
	
		
			
				|  |  | @Component
 | 
	
		
			
				|  |  | public class ClientSearchRequestAspect {
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     private static final String REQ_LIMIT = "req_limit";
 | 
	
		
			
				|  |  |     public static int RESPONSE_STATUS_CODE = 1000;
 | 
	
		
			
				|  |  |     @Around("execution(* com.yihu.jw.base.endpoint.searchClient.ClientSearchEndpoint.saveBaseSearchNoveltyRepeat(..))"
 | 
	
		
			
				|  |  |             +"&& @annotation(com.yihu.jw.base.aop.ClientSearchRequestLimit)")
 | 
	
		
			
				|  |  |     public Object method(ProceedingJoinPoint pjp) throws Throwable{
 | 
	
		
			
				|  |  |         MethodSignature signature = (MethodSignature) pjp.getSignature();
 | 
	
		
			
				|  |  |         Method method = signature.getMethod();//获取被拦截的方法
 | 
	
		
			
				|  |  |         ClientSearchRequestLimit limit = method.getAnnotation(ClientSearchRequestLimit.class);
 | 
	
		
			
				|  |  |         if ( limit == null ){
 | 
	
		
			
				|  |  |             return pjp.proceed();
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         ServletRequestAttributes requestAttributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
 | 
	
		
			
				|  |  |         return requestAttributes;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | }
 |