Commit e704c816 authored by yanzg's avatar yanzg

拦截日志

parent aaa9f24d
package com.yanzuoguang.cloud.aop; package com.yanzuoguang.cloud.aop;
import com.yanzuoguang.util.exception.CodeException;
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;
...@@ -16,7 +17,11 @@ public abstract class AbstractValidateAspect { ...@@ -16,7 +17,11 @@ public abstract class AbstractValidateAspect {
* @return * @return
*/ */
protected static HttpServletRequest getRequest() { protected static HttpServletRequest getRequest() {
return ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
if (attributes == null) {
throw new CodeException("监视错误");
}
return attributes.getRequest();
} }
/** /**
......
...@@ -24,7 +24,7 @@ public class FeignAspect extends AbstractValidateAspect { ...@@ -24,7 +24,7 @@ public class FeignAspect extends AbstractValidateAspect {
/** /**
* AOP的表达式 * AOP的表达式
*/ */
@Pointcut("execution(* *..feign..*(..))") @Pointcut("execution(* *..feign..Feign..*(..))")
public void feignAspect() { public void feignAspect() {
} }
......
...@@ -76,7 +76,7 @@ public class WebAspect extends AbstractValidateAspect implements ThreadNext.Next ...@@ -76,7 +76,7 @@ public class WebAspect extends AbstractValidateAspect implements ThreadNext.Next
/** /**
* exec aop point aspect * exec aop point aspect
*/ */
@Pointcut("execution(* *..web..*(..))") @Pointcut("execution(* *..web..Controller..*(..))")
public void webAspect() { public void webAspect() {
} }
......
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