|
|
@ -7,7 +7,6 @@ import com.gitee.sop.servercommon.annotation.Open; |
|
|
|
import com.gitee.sop.servercommon.bean.OpenContext; |
|
|
|
import com.gitee.sop.servercommon.bean.OpenContext; |
|
|
|
import com.gitee.sop.servercommon.bean.OpenContextImpl; |
|
|
|
import com.gitee.sop.servercommon.bean.OpenContextImpl; |
|
|
|
import com.gitee.sop.servercommon.bean.ParamNames; |
|
|
|
import com.gitee.sop.servercommon.bean.ParamNames; |
|
|
|
import com.gitee.sop.servercommon.bean.ServiceConfig; |
|
|
|
|
|
|
|
import com.gitee.sop.servercommon.bean.ServiceContext; |
|
|
|
import com.gitee.sop.servercommon.bean.ServiceContext; |
|
|
|
import com.gitee.sop.servercommon.util.OpenUtil; |
|
|
|
import com.gitee.sop.servercommon.util.OpenUtil; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
@ -61,8 +60,6 @@ public class ApiArgumentResolver implements SopHandlerMethodArgumentResolver { |
|
|
|
|
|
|
|
|
|
|
|
private RequestMappingHandlerAdapter requestMappingHandlerAdapter; |
|
|
|
private RequestMappingHandlerAdapter requestMappingHandlerAdapter; |
|
|
|
|
|
|
|
|
|
|
|
private static final List<MethodParameter> openApiParams = new ArrayList<>(64); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static { |
|
|
|
static { |
|
|
|
try { |
|
|
|
try { |
|
|
|
pushBuilder = ClassUtils.forName("javax.servlet.http.PushBuilder", |
|
|
|
pushBuilder = ClassUtils.forName("javax.servlet.http.PushBuilder", |
|
|
@ -86,8 +83,8 @@ public class ApiArgumentResolver implements SopHandlerMethodArgumentResolver { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public boolean supportsParameter(MethodParameter methodParameter) { |
|
|
|
public boolean supportsParameter(MethodParameter methodParameter) { |
|
|
|
// 是否有注解
|
|
|
|
// 是否有注解
|
|
|
|
if (hasApiAnnotation(methodParameter)) { |
|
|
|
if (!methodParameter.hasMethodAnnotation(Open.class)) { |
|
|
|
openApiParams.add(methodParameter); |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
Class<?> paramType = methodParameter.getParameterType(); |
|
|
|
Class<?> paramType = methodParameter.getParameterType(); |
|
|
|
// 排除的
|
|
|
|
// 排除的
|
|
|
@ -112,10 +109,6 @@ public class ApiArgumentResolver implements SopHandlerMethodArgumentResolver { |
|
|
|
return !exclude; |
|
|
|
return !exclude; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private boolean hasApiAnnotation(MethodParameter methodParameter) { |
|
|
|
|
|
|
|
return methodParameter.hasMethodAnnotation(Open.class); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public Object resolveArgument( |
|
|
|
public Object resolveArgument( |
|
|
|
MethodParameter methodParameter |
|
|
|
MethodParameter methodParameter |
|
|
@ -127,13 +120,11 @@ public class ApiArgumentResolver implements SopHandlerMethodArgumentResolver { |
|
|
|
(HttpServletRequest) nativeWebRequest.getNativeRequest(), |
|
|
|
(HttpServletRequest) nativeWebRequest.getNativeRequest(), |
|
|
|
(HttpServletResponse) nativeWebRequest.getNativeResponse() |
|
|
|
(HttpServletResponse) nativeWebRequest.getNativeResponse() |
|
|
|
); |
|
|
|
); |
|
|
|
if (openApiParams.contains(methodParameter)) { |
|
|
|
Object paramObj = this.getParamObject(methodParameter, nativeWebRequest); |
|
|
|
Object paramObj = this.getParamObject(methodParameter, nativeWebRequest); |
|
|
|
if (paramObj != null) { |
|
|
|
if (paramObj != null) { |
|
|
|
// JSR-303验证
|
|
|
|
// JSR-303验证
|
|
|
|
paramValidator.validateBizParam(paramObj); |
|
|
|
paramValidator.validateBizParam(paramObj); |
|
|
|
return paramObj; |
|
|
|
return paramObj; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
HandlerMethodArgumentResolver resolver = getOtherArgumentResolver(methodParameter); |
|
|
|
HandlerMethodArgumentResolver resolver = getOtherArgumentResolver(methodParameter); |
|
|
|
if (resolver != null) { |
|
|
|
if (resolver != null) { |
|
|
|