diff --git a/changelog.md b/changelog.md
index a5d8e03b..eaa46040 100644
--- a/changelog.md
+++ b/changelog.md
@@ -1,5 +1,9 @@
# changelog
+## 4.3.2
+
+- 修复微服务方法没有参数时获取不到OpenContext问题
+
## 4.3.1
- 修复serviceId有大小写出现404问题
diff --git a/doc/pom.xml b/doc/pom.xml
index 6e5c1f3c..1d034539 100644
--- a/doc/pom.xml
+++ b/doc/pom.xml
@@ -3,7 +3,7 @@
4.0.0
com.gitee.sop
doc
- 4.3.1-SNAPSHOT
+ 4.3.2-SNAPSHOT
diff --git a/pom.xml b/pom.xml
index 0a470e78..7e1cc792 100644
--- a/pom.xml
+++ b/pom.xml
@@ -11,7 +11,7 @@
4.0.0
com.gitee.sop
sop-parent
- 4.3.1-SNAPSHOT
+ 4.3.2-SNAPSHOT
pom
一个开放平台解决方案项目,基于Spring Cloud实现,目标是能够让用户快速得搭建起自己的开放平台
diff --git a/sop-admin/pom.xml b/sop-admin/pom.xml
index fa9d4283..a655036d 100644
--- a/sop-admin/pom.xml
+++ b/sop-admin/pom.xml
@@ -6,7 +6,7 @@
com.gitee.sop
sop-parent
- 4.3.1-SNAPSHOT
+ 4.3.2-SNAPSHOT
../pom.xml
diff --git a/sop-admin/sop-admin-server/pom.xml b/sop-admin/sop-admin-server/pom.xml
index 61f81fc9..f7df6225 100644
--- a/sop-admin/sop-admin-server/pom.xml
+++ b/sop-admin/sop-admin-server/pom.xml
@@ -5,13 +5,13 @@
com.gitee.sop
sop-parent
- 4.3.1-SNAPSHOT
+ 4.3.2-SNAPSHOT
../../pom.xml
4.0.0
sop-admin-server
- 4.3.1-SNAPSHOT
+ 4.3.2-SNAPSHOT
jar
diff --git a/sop-auth/pom.xml b/sop-auth/pom.xml
index 61862801..14e1721e 100644
--- a/sop-auth/pom.xml
+++ b/sop-auth/pom.xml
@@ -5,7 +5,7 @@
com.gitee.sop
sop-parent
- 4.3.1-SNAPSHOT
+ 4.3.2-SNAPSHOT
../pom.xml
@@ -38,7 +38,7 @@
com.gitee.sop
sdk-java
- 4.3.1-SNAPSHOT
+ 4.3.2-SNAPSHOT
diff --git a/sop-common/pom.xml b/sop-common/pom.xml
index a986fd84..6f715011 100644
--- a/sop-common/pom.xml
+++ b/sop-common/pom.xml
@@ -6,7 +6,7 @@
com.gitee.sop
sop-parent
- 4.3.1-SNAPSHOT
+ 4.3.2-SNAPSHOT
../pom.xml
diff --git a/sop-common/sop-bridge-eureka/pom.xml b/sop-common/sop-bridge-eureka/pom.xml
index 32e614b4..a0690049 100644
--- a/sop-common/sop-bridge-eureka/pom.xml
+++ b/sop-common/sop-bridge-eureka/pom.xml
@@ -5,7 +5,7 @@
com.gitee.sop
sop-common
- 4.3.1-SNAPSHOT
+ 4.3.2-SNAPSHOT
../pom.xml
4.0.0
diff --git a/sop-common/sop-bridge-nacos/pom.xml b/sop-common/sop-bridge-nacos/pom.xml
index f5f3d991..8e44c1ad 100644
--- a/sop-common/sop-bridge-nacos/pom.xml
+++ b/sop-common/sop-bridge-nacos/pom.xml
@@ -5,7 +5,7 @@
com.gitee.sop
sop-common
- 4.3.1-SNAPSHOT
+ 4.3.2-SNAPSHOT
../pom.xml
4.0.0
diff --git a/sop-common/sop-gateway-common/pom.xml b/sop-common/sop-gateway-common/pom.xml
index e83fd8ec..92590ee9 100644
--- a/sop-common/sop-gateway-common/pom.xml
+++ b/sop-common/sop-gateway-common/pom.xml
@@ -5,7 +5,7 @@
com.gitee.sop
sop-common
- 4.3.1-SNAPSHOT
+ 4.3.2-SNAPSHOT
../pom.xml
diff --git a/sop-common/sop-service-common/pom.xml b/sop-common/sop-service-common/pom.xml
index b1441d0a..1e7a1bde 100644
--- a/sop-common/sop-service-common/pom.xml
+++ b/sop-common/sop-service-common/pom.xml
@@ -6,13 +6,13 @@
com.gitee.sop
sop-common
- 4.3.1-SNAPSHOT
+ 4.3.2-SNAPSHOT
../pom.xml
4.0.0
sop-service-common
- 4.3.1-SNAPSHOT
+ 4.3.2-SNAPSHOT
jar
diff --git a/sop-common/sop-service-common/src/main/java/com/gitee/sop/servercommon/interceptor/ServiceContextInterceptor.java b/sop-common/sop-service-common/src/main/java/com/gitee/sop/servercommon/interceptor/ServiceContextInterceptor.java
index f02e54ed..fd4b845a 100644
--- a/sop-common/sop-service-common/src/main/java/com/gitee/sop/servercommon/interceptor/ServiceContextInterceptor.java
+++ b/sop-common/sop-service-common/src/main/java/com/gitee/sop/servercommon/interceptor/ServiceContextInterceptor.java
@@ -1,6 +1,11 @@
package com.gitee.sop.servercommon.interceptor;
+import com.alibaba.fastjson.JSONObject;
+import com.gitee.sop.servercommon.annotation.Open;
+import com.gitee.sop.servercommon.bean.OpenContextImpl;
import com.gitee.sop.servercommon.bean.ServiceContext;
+import com.gitee.sop.servercommon.util.OpenUtil;
+import org.springframework.web.method.HandlerMethod;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
import javax.servlet.http.HttpServletRequest;
@@ -16,6 +21,7 @@ public class ServiceContextInterceptor extends HandlerInterceptorAdapter {
ServiceContext context = ServiceContext.getCurrentContext();
context.setRequest(request);
context.setResponse(response);
+ this.initOpenContextWithNoParam(context, request, handler);
return true;
}
@@ -23,4 +29,22 @@ public class ServiceContextInterceptor extends HandlerInterceptorAdapter {
public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception {
ServiceContext.getCurrentContext().unset();
}
+
+ /**
+ * 修复没有参数的情况下无法获取OpenContext
+ * @param context ServiceContext
+ * @param request HttpServletRequest
+ * @param handler HandlerMethod
+ */
+ private void initOpenContextWithNoParam(ServiceContext context, HttpServletRequest request, Object handler) {
+ if (handler instanceof HandlerMethod) {
+ HandlerMethod handlerMethod = (HandlerMethod) handler;
+ Open open = handlerMethod.getMethodAnnotation(Open.class);
+ if (open != null && handlerMethod.getMethodParameters().length == 0) {
+ JSONObject requestParams = OpenUtil.getRequestParams(request);
+ OpenContextImpl openContext = new OpenContextImpl(requestParams);
+ context.setOpenContext(openContext);
+ }
+ }
+ }
}
diff --git a/sop-example/pom.xml b/sop-example/pom.xml
index a9a58aef..aa73aaa8 100644
--- a/sop-example/pom.xml
+++ b/sop-example/pom.xml
@@ -5,7 +5,7 @@
com.gitee.sop
sop-parent
- 4.3.1-SNAPSHOT
+ 4.3.2-SNAPSHOT
../pom.xml
diff --git a/sop-example/sop-springmvc/pom.xml b/sop-example/sop-springmvc/pom.xml
index bc94f4eb..b3e274be 100644
--- a/sop-example/sop-springmvc/pom.xml
+++ b/sop-example/sop-springmvc/pom.xml
@@ -5,7 +5,7 @@
com.gitee.sop
sop-parent
- 4.3.1-SNAPSHOT
+ 4.3.2-SNAPSHOT
../../pom.xml
diff --git a/sop-example/sop-story/pom.xml b/sop-example/sop-story/pom.xml
index 7c9fde05..52fc6d81 100644
--- a/sop-example/sop-story/pom.xml
+++ b/sop-example/sop-story/pom.xml
@@ -4,7 +4,7 @@
com.gitee.sop
sop-parent
- 4.3.1-SNAPSHOT
+ 4.3.2-SNAPSHOT
../../pom.xml
diff --git a/sop-example/sop-story/src/main/java/com/gitee/sop/storyweb/controller/Example1001_BaseController.java b/sop-example/sop-story/src/main/java/com/gitee/sop/storyweb/controller/Example1001_BaseController.java
index 879d2762..0c6679c8 100644
--- a/sop-example/sop-story/src/main/java/com/gitee/sop/storyweb/controller/Example1001_BaseController.java
+++ b/sop-example/sop-story/src/main/java/com/gitee/sop/storyweb/controller/Example1001_BaseController.java
@@ -111,6 +111,16 @@ public class Example1001_BaseController {
return result;
}
+ @Open(value = "story.system.param.get2")
+ @GetMapping("/get/system/param/v2")
+ public StoryResult systemParam2() {
+ StoryResult result = new StoryResult();
+ OpenContext openContext = ServiceContext.getCurrentContext().getOpenContext();
+ String token = openContext.getAppAuthToken();
+ result.setName(token);
+ return result;
+ }
+
// 参数绑定,少量参数可以这样写,参数多了建议放进类里面
@Open(value = "story.oneparam")
@GetMapping("/oneParam/v1")
diff --git a/sop-gateway/pom.xml b/sop-gateway/pom.xml
index 741e5fed..4dba0d52 100644
--- a/sop-gateway/pom.xml
+++ b/sop-gateway/pom.xml
@@ -4,7 +4,7 @@
com.gitee.sop
sop-parent
- 4.3.1-SNAPSHOT
+ 4.3.2-SNAPSHOT
../pom.xml
diff --git a/sop-sdk/pom.xml b/sop-sdk/pom.xml
index bebee007..9d1822f5 100644
--- a/sop-sdk/pom.xml
+++ b/sop-sdk/pom.xml
@@ -6,7 +6,7 @@
com.gitee.sop
sop-parent
- 4.3.1-SNAPSHOT
+ 4.3.2-SNAPSHOT
../pom.xml
diff --git a/sop-sdk/sdk-java/pom.xml b/sop-sdk/sdk-java/pom.xml
index 924b9f76..f5dbaa82 100644
--- a/sop-sdk/sdk-java/pom.xml
+++ b/sop-sdk/sdk-java/pom.xml
@@ -4,13 +4,13 @@
com.gitee.sop
sop-parent
- 4.3.1-SNAPSHOT
+ 4.3.2-SNAPSHOT
../../pom.xml
4.0.0
sdk-java
- 4.3.1-SNAPSHOT
+ 4.3.2-SNAPSHOT
diff --git a/sop-test/pom.xml b/sop-test/pom.xml
index f4aa0153..85c3584c 100644
--- a/sop-test/pom.xml
+++ b/sop-test/pom.xml
@@ -5,7 +5,7 @@
com.gitee.sop
sop-parent
- 4.3.1-SNAPSHOT
+ 4.3.2-SNAPSHOT
../pom.xml
diff --git a/sop-test/src/test/java/com/gitee/sop/test/AllInOneTest.java b/sop-test/src/test/java/com/gitee/sop/test/AllInOneTest.java
index 7ee918a8..8dcca3ff 100644
--- a/sop-test/src/test/java/com/gitee/sop/test/AllInOneTest.java
+++ b/sop-test/src/test/java/com/gitee/sop/test/AllInOneTest.java
@@ -371,6 +371,24 @@ public class AllInOneTest extends TestBase {
client.execute(requestBuilder);
}
+ /**
+ * 没有参数获取token
+ */
+ public void testNoParamToken() {
+ String token = "asdfasdfadsf";
+ Client.RequestBuilder requestBuilder = new Client.RequestBuilder()
+ .method("story.system.param.get2")
+ .version("1.0")
+ .appAuthToken(token)
+ .httpMethod(HttpTool.HTTPMethod.GET)
+ .callback((requestInfo, responseData) -> {
+ System.out.println(responseData);
+ Assert.assertTrue(responseData.contains(token));
+ });
+
+ client.execute(requestBuilder);
+ }
+
static class BizContent extends HashMap {
public BizContent add(String key, Object value) {
this.put(key, value);
diff --git a/sop-website/pom.xml b/sop-website/pom.xml
index 17563bc3..ee4d79f2 100644
--- a/sop-website/pom.xml
+++ b/sop-website/pom.xml
@@ -6,7 +6,7 @@
com.gitee.sop
sop-parent
- 4.3.1-SNAPSHOT
+ 4.3.2-SNAPSHOT
../pom.xml
diff --git a/sop-website/sop-website-server/pom.xml b/sop-website/sop-website-server/pom.xml
index 566b2aad..0b61ac90 100644
--- a/sop-website/sop-website-server/pom.xml
+++ b/sop-website/sop-website-server/pom.xml
@@ -5,7 +5,7 @@
com.gitee.sop
sop-website
- 4.3.1-SNAPSHOT
+ 4.3.2-SNAPSHOT
../pom.xml