pull/1/head
tanghc 5 years ago
parent 64cb58a9ca
commit f8ff5e7e8e
  1. 9
      sop-common/sop-service-common/src/main/java/com/gitee/sop/servercommon/param/ServiceParamValidator.java
  2. 6
      sop-example/sop-story/sop-story-web/src/main/java/com/gitee/sop/storyweb/controller/AlipayController.java
  3. 2
      sop-example/sop-story/sop-story-web/src/main/resources/application-dev.properties
  4. 2
      sop-test/src/test/java/com/gitee/sop/test/AlipayClientPostTest.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<String> SYSTEM_PACKAGE_LIST = Arrays.asList("java.lang", "java.math");
private static final List<String> 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();

@ -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;
}

@ -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

@ -244,6 +244,8 @@ public class AlipayClientPostTest extends TestBase {
params.put("timestamp", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
// 业务参数
Map<String, String> bizContent = new HashMap<>();
bizContent.put("name", "Jim");
bizContent.put("age", "2");
params.put("biz_content", JSON.toJSONString(bizContent));

Loading…
Cancel
Save