mirror of
https://gitee.com/durcframework/SOP.git
synced 2025-08-12 07:02:14 +08:00
JSR-303优化
This commit is contained in:
@@ -129,11 +129,9 @@ public class ApiArgumentResolver implements SopHandlerMethodArgumentResolver {
|
|||||||
if (paramObj instanceof OpenContext) {
|
if (paramObj instanceof OpenContext) {
|
||||||
paramObj = ((OpenContext) paramObj).getBizObject();
|
paramObj = ((OpenContext) paramObj).getBizObject();
|
||||||
}
|
}
|
||||||
if (paramObj != null) {
|
// JSR-303验证
|
||||||
// JSR-303验证
|
paramValidator.validateBizParam(paramObj);
|
||||||
paramValidator.validateBizParam(paramObj);
|
return ret;
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
HandlerMethodArgumentResolver resolver = getOtherArgumentResolver(methodParameter);
|
HandlerMethodArgumentResolver resolver = getOtherArgumentResolver(methodParameter);
|
||||||
if (resolver != null) {
|
if (resolver != null) {
|
||||||
|
@@ -15,6 +15,7 @@ import java.lang.reflect.Field;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -70,6 +71,7 @@ public class ServiceParamValidator implements ParamValidator {
|
|||||||
* 1. 不为基本类型;
|
* 1. 不为基本类型;
|
||||||
* 2. 不为java自带的类型;
|
* 2. 不为java自带的类型;
|
||||||
* 3. 不为枚举
|
* 3. 不为枚举
|
||||||
|
* 4. 不为Map
|
||||||
* @param field field
|
* @param field field
|
||||||
* @return true,是自定义的
|
* @return true,是自定义的
|
||||||
*/
|
*/
|
||||||
@@ -78,6 +80,9 @@ public class ServiceParamValidator implements ParamValidator {
|
|||||||
if (fieldType.isPrimitive()) {
|
if (fieldType.isPrimitive()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if (Map.class.isAssignableFrom(fieldType)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
Class<?> declaringClass = field.getDeclaringClass();
|
Class<?> declaringClass = field.getDeclaringClass();
|
||||||
boolean isEnum = declaringClass == field.getType() && declaringClass.isEnum();
|
boolean isEnum = declaringClass == field.getType() && declaringClass.isEnum();
|
||||||
if (isEnum) {
|
if (isEnum) {
|
||||||
@@ -88,7 +93,12 @@ public class ServiceParamValidator implements ParamValidator {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
String packageName = aPackage.getName();
|
String packageName = aPackage.getName();
|
||||||
return !SYSTEM_PACKAGE_LIST.contains(packageName);
|
for (String prefix : SYSTEM_PACKAGE_LIST) {
|
||||||
|
if (packageName.startsWith(prefix)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private RuntimeException getValidateBizParamException(String errorMsg) {
|
private RuntimeException getValidateBizParamException(String errorMsg) {
|
||||||
|
Reference in New Issue
Block a user