diff --git a/sop-common/sop-service-common/src/main/java/com/gitee/sop/servercommon/param/ServiceParamValidator.java b/sop-common/sop-service-common/src/main/java/com/gitee/sop/servercommon/param/ServiceParamValidator.java index ede3fdbf..c32c3762 100644 --- a/sop-common/sop-service-common/src/main/java/com/gitee/sop/servercommon/param/ServiceParamValidator.java +++ b/sop-common/sop-service-common/src/main/java/com/gitee/sop/servercommon/param/ServiceParamValidator.java @@ -29,7 +29,7 @@ public class ServiceParamValidator implements ParamValidator { private static final String COMMA = ","; private static Object[] EMPTY_OBJ_ARRAY = {}; - private static final List SYSTEM_PACKAGE_LIST = Arrays.asList("java.lang", "java.math"); + private static final List SYSTEM_PACKAGE_LIST = Arrays.asList("java.lang", "java.math", "java.util", "sun.util"); private static javax.validation.Validator validator; @@ -84,8 +84,11 @@ public class ServiceParamValidator implements ParamValidator { return false; } Class declaringClass = field.getDeclaringClass(); - boolean isEnum = declaringClass == field.getType() && declaringClass.isEnum(); - if (isEnum) { + boolean isSame = declaringClass == fieldType; + boolean isAssignableFrom = declaringClass.isAssignableFrom(fieldType) + || fieldType.isAssignableFrom(declaringClass); + // 如果是相同类,或者有继承关系不校验。 + if (isSame || isAssignableFrom) { return false; } Package aPackage = fieldType.getPackage(); diff --git a/sop-example/sop-story/sop-story-web/src/main/java/com/gitee/sop/storyweb/controller/AlipayController.java b/sop-example/sop-story/sop-story-web/src/main/java/com/gitee/sop/storyweb/controller/AlipayController.java index d9121ec6..7cfe7817 100644 --- a/sop-example/sop-story/sop-story-web/src/main/java/com/gitee/sop/storyweb/controller/AlipayController.java +++ b/sop-example/sop-story/sop-story-web/src/main/java/com/gitee/sop/storyweb/controller/AlipayController.java @@ -1,6 +1,7 @@ package com.gitee.sop.storyweb.controller; import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; import com.gitee.sop.servercommon.annotation.ApiAbility; import com.gitee.sop.servercommon.annotation.ApiMapping; import com.gitee.sop.servercommon.bean.OpenContext; @@ -17,6 +18,7 @@ import lombok.Data; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.BeanUtils; import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; @@ -132,10 +134,10 @@ public class AlipayController { // 遗留接口具备开放平台能力 @ApiAbility @GetMapping("getStory2") - public StoryResult getStory2_0() { + public StoryResult getStory2_0(@RequestBody JSONObject param) { StoryResult story = new StoryResult(); story.setId(1L); - story.setName("海底小纵队(默认版本号)"); + story.setName("海底小纵队(默认版本号),param:" + param); return story; } diff --git a/sop-example/sop-story/sop-story-web/src/main/resources/application-dev.properties b/sop-example/sop-story/sop-story-web/src/main/resources/application-dev.properties index f0150321..eea4f7c8 100644 --- a/sop-example/sop-story/sop-story-web/src/main/resources/application-dev.properties +++ b/sop-example/sop-story/sop-story-web/src/main/resources/application-dev.properties @@ -3,6 +3,8 @@ spring.application.name=story-service # nacos注册中心 spring.cloud.nacos.discovery.server-addr=127.0.0.1:8848 +# 如果有context-path,必须配下面这句 +#spring.cloud.nacos.discovery.metadata.server.servlet.context-path=/story-service # dubbo配置 dubbo.protocol.name=dubbo diff --git a/sop-test/src/test/java/com/gitee/sop/test/AlipayClientPostTest.java b/sop-test/src/test/java/com/gitee/sop/test/AlipayClientPostTest.java index 56d13098..189ea710 100644 --- a/sop-test/src/test/java/com/gitee/sop/test/AlipayClientPostTest.java +++ b/sop-test/src/test/java/com/gitee/sop/test/AlipayClientPostTest.java @@ -244,6 +244,8 @@ public class AlipayClientPostTest extends TestBase { params.put("timestamp", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date())); // 业务参数 Map bizContent = new HashMap<>(); + bizContent.put("name", "Jim"); + bizContent.put("age", "2"); params.put("biz_content", JSON.toJSONString(bizContent));