This commit is contained in:
tanghc
2021-03-25 14:33:43 +08:00
parent 8aeb6c16bf
commit 842f3a2ae5

View File

@@ -40,11 +40,15 @@ public class ServiceContextInterceptor extends HandlerInterceptorAdapter {
if (handler instanceof HandlerMethod) { if (handler instanceof HandlerMethod) {
HandlerMethod handlerMethod = (HandlerMethod) handler; HandlerMethod handlerMethod = (HandlerMethod) handler;
Open open = handlerMethod.getMethodAnnotation(Open.class); Open open = handlerMethod.getMethodAnnotation(Open.class);
if (open != null && handlerMethod.getMethodParameters().length == 0) { if (open != null && getArrayLength(handlerMethod.getMethodParameters()) == 0) {
JSONObject requestParams = OpenUtil.getRequestParams(request); JSONObject requestParams = OpenUtil.getRequestParams(request);
OpenContextImpl openContext = new OpenContextImpl(requestParams); OpenContextImpl openContext = new OpenContextImpl(requestParams);
context.setOpenContext(openContext); context.setOpenContext(openContext);
} }
} }
} }
private static <T> int getArrayLength(T[] arr) {
return arr == null ? 0 : arr.length;
}
} }