Commit a106f9bd authored by yanzg's avatar yanzg

常规BUG的修改

parent 5d4ff0f8
...@@ -19,6 +19,7 @@ import org.aspectj.lang.reflect.MethodSignature; ...@@ -19,6 +19,7 @@ import org.aspectj.lang.reflect.MethodSignature;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import javax.servlet.ServletRequest; import javax.servlet.ServletRequest;
...@@ -41,6 +42,9 @@ public class WebAspect extends BaseRequestAspect { ...@@ -41,6 +42,9 @@ public class WebAspect extends BaseRequestAspect {
@Autowired @Autowired
private TokenServiceCall tokenServiceCall; private TokenServiceCall tokenServiceCall;
@Value("${yzg.reqUrl:order,check,use}")
private String reqUrl;
/** /**
* exec aop point aspect * exec aop point aspect
*/ */
...@@ -115,19 +119,50 @@ public class WebAspect extends BaseRequestAspect { ...@@ -115,19 +119,50 @@ public class WebAspect extends BaseRequestAspect {
* @throws NoSuchMethodException * @throws NoSuchMethodException
*/ */
private Type getReturnType(ProceedingJoinPoint joinPoint) { private Type getReturnType(ProceedingJoinPoint joinPoint) {
Method m = getMethod(joinPoint);
Type t = m.getAnnotatedReturnType().getType();
return t;
}
/**
* 获取返回的至类型
*
* @param joinPoint
* @return
* @throws NoSuchMethodException
*/
private Method getMethod(ProceedingJoinPoint joinPoint) {
//获取返回值类型 //获取返回值类型
Signature s = joinPoint.getSignature(); Signature s = joinPoint.getSignature();
MethodSignature ms = (MethodSignature) s; MethodSignature ms = (MethodSignature) s;
Method m = ms.getMethod(); Method m = ms.getMethod();
Type t = m.getAnnotatedReturnType().getType(); return m;
return t;
} }
/**
* 执行方法
*
* @param joinPoint 需要执行的方法
* @param name 方法名称
* @return 返回结果
* @throws Throwable
*/
private Object executeMethod(ProceedingJoinPoint joinPoint, String name) throws Throwable { private Object executeMethod(ProceedingJoinPoint joinPoint, String name) throws Throwable {
boolean dataArgs = joinPoint.getArgs().length != 1 boolean dataArgs = joinPoint.getArgs().length != 1
|| joinPoint.getArgs().length == 1 && || joinPoint.getArgs().length == 1 &&
(joinPoint.getArgs()[0] instanceof ServletResponse || joinPoint.getArgs()[0] instanceof ServletRequest); (joinPoint.getArgs()[0] instanceof ServletResponse || joinPoint.getArgs()[0] instanceof ServletRequest);
if (dataArgs) { Method method = getMethod(joinPoint);
boolean isUrl = false;
if (!StringHelper.isEmpty(reqUrl)) {
String[] urls = reqUrl.split(",");
for (String url : urls) {
if (method.getName().matches(url)) {
isUrl = true;
break;
}
}
}
if (dataArgs || !isUrl) {
return joinPoint.proceed(); return joinPoint.proceed();
} else { } else {
// 获取请求编号 // 获取请求编号
......
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