Commit 85a26349 authored by yanzg's avatar yanzg

接口文档的支持

parent 6e951e60
...@@ -3,9 +3,6 @@ package com.yanzuoguang.cloud.aop; ...@@ -3,9 +3,6 @@ package com.yanzuoguang.cloud.aop;
import com.yanzuoguang.cloud.service.TokenServiceCall; import com.yanzuoguang.cloud.service.TokenServiceCall;
import com.yanzuoguang.token.TokenHelper; import com.yanzuoguang.token.TokenHelper;
import com.yanzuoguang.util.exception.ExceptionHelper; import com.yanzuoguang.util.exception.ExceptionHelper;
import com.yanzuoguang.util.helper.JsonHelper;
import com.yanzuoguang.util.helper.StringHelper;
import com.yanzuoguang.util.vo.Ref;
import com.yanzuoguang.util.vo.ResponseResult; import com.yanzuoguang.util.vo.ResponseResult;
import org.aspectj.lang.ProceedingJoinPoint; import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.Signature; import org.aspectj.lang.Signature;
...@@ -15,11 +12,11 @@ import org.aspectj.lang.annotation.Pointcut; ...@@ -15,11 +12,11 @@ import org.aspectj.lang.annotation.Pointcut;
import org.aspectj.lang.reflect.MethodSignature; import org.aspectj.lang.reflect.MethodSignature;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.lang.reflect.Type; import java.lang.reflect.Type;
import java.util.List;
/** /**
* LogsAspect(接口请求日志切面) * LogsAspect(接口请求日志切面)
...@@ -42,6 +39,14 @@ public class WebAspect extends BaseRequestAspect { ...@@ -42,6 +39,14 @@ public class WebAspect extends BaseRequestAspect {
@Value("${yzg.gateway:^.*gateway.*$}") @Value("${yzg.gateway:^.*gateway.*$}")
private String gateWay; private String gateWay;
@Autowired
private ApplicationContext context;
/**
* 是否存在初始化方法
*/
private WebAssecptInit webAssecptInit;
/** /**
* exec aop point aspect * exec aop point aspect
*/ */
...@@ -71,6 +76,14 @@ public class WebAspect extends BaseRequestAspect { ...@@ -71,6 +76,14 @@ public class WebAspect extends BaseRequestAspect {
boolean isInit = false; boolean isInit = false;
try { try {
isInit = tokenServiceCall.tokenInit(); isInit = tokenServiceCall.tokenInit();
if (webAssecptInit == null && context.containsBean("webAssecptInit")) {
webAssecptInit = context.getBean(WebAssecptInit.class);
}
if (webAssecptInit != null) {
for (Object arg : joinPoint.getArgs()) {
webAssecptInit.init(arg);
}
}
result = executeMethod(joinPoint); result = executeMethod(joinPoint);
return result; return result;
} catch (Exception e) { } catch (Exception e) {
......
package com.yanzuoguang.cloud.aop;
public interface WebAssecptInit {
/**
* 对请求的数据初始化
*
* @param req 需要初始化的数据
*/
void init(Object req);
}
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