From a9a3dcdd0aa958e93ff228fe2d14cf6bd40e3dab Mon Sep 17 00:00:00 2001 From: tanghc Date: Thu, 25 Feb 2021 13:43:09 +0800 Subject: [PATCH] 4.2.7 --- changelog.md | 1 + .../gitee/sop/servercommon/param/ApiArgumentResolver.java | 7 +++---- .../storyweb/controller/Example1001_BaseController.java | 4 ++-- sop-sdk/sdk-python/common/OpenClient.py | 6 ++---- sop-sdk/sdk-python/test/test.py | 2 +- 5 files changed, 9 insertions(+), 11 deletions(-) diff --git a/changelog.md b/changelog.md index a93fda6e..cc58518b 100644 --- a/changelog.md +++ b/changelog.md @@ -3,6 +3,7 @@ ## 4.2.7 - 修复两个微服务相同path问题 +- 修复Python-SDK下参数传递问题 ## 4.2.6 diff --git a/sop-common/sop-service-common/src/main/java/com/gitee/sop/servercommon/param/ApiArgumentResolver.java b/sop-common/sop-service-common/src/main/java/com/gitee/sop/servercommon/param/ApiArgumentResolver.java index bed09eaf..19a9db5b 100644 --- a/sop-common/sop-service-common/src/main/java/com/gitee/sop/servercommon/param/ApiArgumentResolver.java +++ b/sop-common/sop-service-common/src/main/java/com/gitee/sop/servercommon/param/ApiArgumentResolver.java @@ -143,7 +143,6 @@ public class ApiArgumentResolver implements SopHandlerMethodArgumentResolver { Object paramObj = this.getParamObject(methodParameter, nativeWebRequest); if (paramObj != null) { // JSR-303验证 - if (paramObj instanceof SingleParameterWrapper) { SingleParameterWrapper parameterWrapper = (SingleParameterWrapper) paramObj; paramValidator.validateBizParam(parameterWrapper.getWrapperObject()); @@ -203,10 +202,10 @@ public class ApiArgumentResolver implements SopHandlerMethodArgumentResolver { return singleParameterWrapper; } Object param; - // 如果是json字符串 - if (JSONValidator.from(bizContent).validate()) { + try { param = JSON.parseObject(bizContent, parameterType); - } else { + } catch (Exception e) { + log.error("非json参数,biz_content:{}, requestParams:{}", bizContent, requestParams); // 否则认为是 aa=1&bb=33 形式 Map query = OpenUtil.parseQueryToMap(bizContent); param = new JSONObject(query).toJavaObject(parameterType); 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 3f4b9c2c..498ffc29 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 @@ -269,12 +269,12 @@ public class Example1001_BaseController { @Open(value = "member.info.get") @RequestMapping("/member/info/get") - public MemberInfoGetResult bigData(MemberInfoGetParam param) { + public MemberInfoGetResult memberInfoGet(MemberInfoGetParam param) { MemberInfoGetResult result = new MemberInfoGetResult(); MemberInfoGetResultMemberInfo memberInfo = new MemberInfoGetResultMemberInfo(); memberInfo.setIsVip((byte)1); memberInfo.setVipEndtime(new Date()); - result.setName(param.getName()); + result.setName(JSON.toJSONString(param)); result.setId(11); result.setMemberInfo(memberInfo); return result; diff --git a/sop-sdk/sdk-python/common/OpenClient.py b/sop-sdk/sdk-python/common/OpenClient.py index 821c5f3e..8f60464b 100644 --- a/sop-sdk/sdk-python/common/OpenClient.py +++ b/sop-sdk/sdk-python/common/OpenClient.py @@ -103,15 +103,13 @@ class OpenClient: 'charset': 'UTF-8', 'sign_type': 'RSA2', 'timestamp': time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()), - 'version': request.get_version() + 'version': request.get_version(), + 'biz_content': json.dumps(params) } if token is not None: all_params['access_token'] = token - # 添加业务参数 - all_params.update(params) - # 构建sign sign = SignUtil.create_sign(all_params, self.__private_key, 'RSA2') all_params['sign'] = sign diff --git a/sop-sdk/sdk-python/test/test.py b/sop-sdk/sdk-python/test/test.py index f98400cf..f249a3a0 100644 --- a/sop-sdk/sdk-python/test/test.py +++ b/sop-sdk/sdk-python/test/test.py @@ -48,7 +48,7 @@ class MyTestCase(unittest.TestCase): # for f in files.values(): # f.close() - if response.is_success(): + if response.get('code') == '10000': print 'response: ', response print 'is_vip:', response.get('member_info').get('is_vip', 0) else: