From a577df49c1753dd4689dce2f8cf649416249f0b7 Mon Sep 17 00:00:00 2001 From: tanghc Date: Thu, 25 Feb 2021 11:32:55 +0800 Subject: [PATCH] 4.2.7 --- .../Example1001_BaseController.java | 16 ++++++++ .../controller/param/MemberInfoGetParam.java | 34 ++++++++++++++++ .../result/MemberInfoGetResult.java | 39 +++++++++++++++++++ .../result/MemberInfoGetResultMemberInfo.java | 29 ++++++++++++++ sop-sdk/sdk-go/common/OpenClient.go | 6 +-- 5 files changed, 121 insertions(+), 3 deletions(-) create mode 100644 sop-example/sop-story/src/main/java/com/gitee/sop/storyweb/controller/param/MemberInfoGetParam.java create mode 100644 sop-example/sop-story/src/main/java/com/gitee/sop/storyweb/controller/result/MemberInfoGetResult.java create mode 100644 sop-example/sop-story/src/main/java/com/gitee/sop/storyweb/controller/result/MemberInfoGetResultMemberInfo.java 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 97f4ae20..3f4b9c2c 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 @@ -9,9 +9,12 @@ import com.gitee.sop.servercommon.bean.ServiceContext; import com.gitee.sop.servercommon.exception.ServiceException; import com.gitee.sop.storyweb.controller.param.CategoryParam; import com.gitee.sop.storyweb.controller.param.LargeTextParam; +import com.gitee.sop.storyweb.controller.param.MemberInfoGetParam; import com.gitee.sop.storyweb.controller.param.StoryParam; import com.gitee.sop.storyweb.controller.param.TypeEnum; import com.gitee.sop.storyweb.controller.result.CategoryResult; +import com.gitee.sop.storyweb.controller.result.MemberInfoGetResult; +import com.gitee.sop.storyweb.controller.result.MemberInfoGetResultMemberInfo; import com.gitee.sop.storyweb.controller.result.StoryResult; import com.gitee.sop.storyweb.controller.result.TestResult; import com.gitee.sop.storyweb.controller.result.TreeResult; @@ -264,4 +267,17 @@ public class Example1001_BaseController { return map; } + @Open(value = "member.info.get") + @RequestMapping("/member/info/get") + public MemberInfoGetResult bigData(MemberInfoGetParam param) { + MemberInfoGetResult result = new MemberInfoGetResult(); + MemberInfoGetResultMemberInfo memberInfo = new MemberInfoGetResultMemberInfo(); + memberInfo.setIsVip((byte)1); + memberInfo.setVipEndtime(new Date()); + result.setName(param.getName()); + result.setId(11); + result.setMemberInfo(memberInfo); + return result; + } + } diff --git a/sop-example/sop-story/src/main/java/com/gitee/sop/storyweb/controller/param/MemberInfoGetParam.java b/sop-example/sop-story/src/main/java/com/gitee/sop/storyweb/controller/param/MemberInfoGetParam.java new file mode 100644 index 00000000..4f17974d --- /dev/null +++ b/sop-example/sop-story/src/main/java/com/gitee/sop/storyweb/controller/param/MemberInfoGetParam.java @@ -0,0 +1,34 @@ +package com.gitee.sop.storyweb.controller.param; + +/** + * 请求参数 + */ +public class MemberInfoGetParam { + private String name; + private Integer age; + private String address; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Integer getAge() { + return age; + } + + public void setAge(Integer age) { + this.age = age; + } + + public String getAddress() { + return address; + } + + public void setAddress(String address) { + this.address = address; + } +} diff --git a/sop-example/sop-story/src/main/java/com/gitee/sop/storyweb/controller/result/MemberInfoGetResult.java b/sop-example/sop-story/src/main/java/com/gitee/sop/storyweb/controller/result/MemberInfoGetResult.java new file mode 100644 index 00000000..5dd5c69f --- /dev/null +++ b/sop-example/sop-story/src/main/java/com/gitee/sop/storyweb/controller/result/MemberInfoGetResult.java @@ -0,0 +1,39 @@ +package com.gitee.sop.storyweb.controller.result; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * 接口返回结果 + */ +public class MemberInfoGetResult { + + private Integer id; + private String name; + + @JsonProperty("member_info") + private MemberInfoGetResultMemberInfo memberInfo; + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public MemberInfoGetResultMemberInfo getMemberInfo() { + return memberInfo; + } + + public void setMemberInfo(MemberInfoGetResultMemberInfo memberInfo) { + this.memberInfo = memberInfo; + } +} diff --git a/sop-example/sop-story/src/main/java/com/gitee/sop/storyweb/controller/result/MemberInfoGetResultMemberInfo.java b/sop-example/sop-story/src/main/java/com/gitee/sop/storyweb/controller/result/MemberInfoGetResultMemberInfo.java new file mode 100644 index 00000000..9b04cdd1 --- /dev/null +++ b/sop-example/sop-story/src/main/java/com/gitee/sop/storyweb/controller/result/MemberInfoGetResultMemberInfo.java @@ -0,0 +1,29 @@ +package com.gitee.sop.storyweb.controller.result; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import java.util.Date; + +public class MemberInfoGetResultMemberInfo { + @JsonProperty("is_vip") + private Byte isVip; + + @JsonProperty("vip_endtime") + private Date vipEndtime; + + public Byte getIsVip() { + return isVip; + } + + public void setIsVip(Byte isVip) { + this.isVip = isVip; + } + + public Date getVipEndtime() { + return vipEndtime; + } + + public void setVipEndtime(Date vipEndtime) { + this.vipEndtime = vipEndtime; + } +} \ No newline at end of file diff --git a/sop-sdk/sdk-go/common/OpenClient.go b/sop-sdk/sdk-go/common/OpenClient.go index 23289c52..682daec7 100644 --- a/sop-sdk/sdk-go/common/OpenClient.go +++ b/sop-sdk/sdk-go/common/OpenClient.go @@ -66,13 +66,11 @@ func parseResponseResult(iRequest IRequest, response string) []byte { if err != nil { panic(err) } - requestId := responseRoot["request_id"].(string) var responseDataMap = responseRoot["error_response"] if responseDataMap == nil { dataName := strings.ReplaceAll(iRequest.GetMethod(), ".", "_") + "_response" responseDataMap = responseRoot[dataName] } - responseDataMap.(map[string]interface{})["request_id"] = requestId // json数据 dataJsonBytes, _ := json.Marshal(responseDataMap) return dataJsonBytes @@ -92,10 +90,12 @@ func (client OpenClient) buildParams(iRequest IRequest, params map[string]interf allParams["access_token"] = token } + bizParams := map[string]interface{}{} // 添加业务参数 for k, v := range params { - allParams[k] = ToString(v) + bizParams[k] = v } + allParams["biz_content"] = ToString(bizParams) // 构建sign sign := CreateSign(allParams, client.PrivateKey, "RSA2")