pull/10/MERGE
tanghc 4 years ago
parent 4b135a62dd
commit 7bae549b30
  1. 2
      sop-common/sop-service-common/src/main/java/com/gitee/sop/servercommon/param/ApiArgumentResolver.java
  2. 11
      sop-example/sop-story/src/main/java/com/gitee/sop/storyweb/controller/Example1001_BaseController.java
  3. 20
      sop-example/sop-story/src/main/java/com/gitee/sop/storyweb/controller/param/ArrayElementParam.java
  4. 6
      sop-sdk/sdk-rust/sdk-test/src/main.rs
  5. 6
      sop-sdk/sdk-rust/sdk/src/client.rs
  6. 63
      sop-test/src/test/java/com/gitee/sop/test/ArrayTest.java

@ -205,7 +205,7 @@ public class ApiArgumentResolver implements SopHandlerMethodArgumentResolver {
try { try {
param = JSON.parseObject(bizContent, parameterType); param = JSON.parseObject(bizContent, parameterType);
} catch (Exception e) { } catch (Exception e) {
log.error("非json参数,biz_content:{}, requestParams:{}", bizContent, requestParams); log.error("非json参数, \nbiz_content:{}\nrequestParams:{}", bizContent, requestParams, e);
// 否则认为是 aa=1&bb=33 形式 // 否则认为是 aa=1&bb=33 形式
Map<String, Object> query = OpenUtil.parseQueryToMap(bizContent); Map<String, Object> query = OpenUtil.parseQueryToMap(bizContent);
param = new JSONObject(query).toJavaObject(parameterType); param = new JSONObject(query).toJavaObject(parameterType);

@ -7,6 +7,7 @@ import com.gitee.sop.servercommon.annotation.Open;
import com.gitee.sop.servercommon.bean.OpenContext; import com.gitee.sop.servercommon.bean.OpenContext;
import com.gitee.sop.servercommon.bean.ServiceContext; import com.gitee.sop.servercommon.bean.ServiceContext;
import com.gitee.sop.servercommon.exception.ServiceException; import com.gitee.sop.servercommon.exception.ServiceException;
import com.gitee.sop.storyweb.controller.param.ArrayElementParam;
import com.gitee.sop.storyweb.controller.param.CategoryParam; import com.gitee.sop.storyweb.controller.param.CategoryParam;
import com.gitee.sop.storyweb.controller.param.LargeTextParam; import com.gitee.sop.storyweb.controller.param.LargeTextParam;
import com.gitee.sop.storyweb.controller.param.MemberInfoGetParam; import com.gitee.sop.storyweb.controller.param.MemberInfoGetParam;
@ -159,6 +160,16 @@ public class Example1001_BaseController {
return result; return result;
} }
@ApiOperation(value = "接收数组", notes = "接收数组")
@Open(value = "story.listparam")
@PostMapping(value = "/get/listparam/v1")
public StoryResult listparam(@RequestBody ArrayElementParam story) {
StoryResult result = new StoryResult();
result.setId(11L);
result.setName(JSON.toJSONString(story));
return result;
}
@Open(value = "story.get.large") @Open(value = "story.get.large")
@RequestMapping("/get/large/v1") @RequestMapping("/get/large/v1")
public StoryResult getStoryLarge(LargeTextParam param) { public StoryResult getStoryLarge(LargeTextParam param) {

@ -0,0 +1,20 @@
package com.gitee.sop.storyweb.controller.param;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
/**
* @author tanghc
*/
@Data
public class ArrayElementParam {
@ApiModelProperty(value = "名字", required = true, example = "白雪公主", position = 1)
private String name;
@ApiModelProperty(value = "数组", required = true, dataType = "List", example = "白雪公主", position = 2)
private List<StoryParam> list;
}

@ -13,11 +13,11 @@ fn main() {
// 创建请求客户端 // 创建请求客户端
let client = OpenClient { let client = OpenClient {
// 应用ID // 应用ID
app_id: "2020051325943082302177280", app_id: "201904035630907729292csharp",
// 应用私钥 // 应用私钥
private_key: "MIICXAIBAAKBgQCHJlAPN+1dCbgc3HiahQkT2W/skecGWOCkSX4CPvEc8oIk6544\nxihEwShHnfrapiQdF2fndv5agrhg4FyOHheST42L5MnCk+4Km+mWm5GDvmFS7Sa2\naZ5o3regY0MUoJ7D74dYjE3UYFuTujAXiXjGpAwa9qOcKotov5LCkSfUeQIDAQAB\nAoGAB1cyw8LYRQSHQCUO9Wiaq730jPNHSrJW4EGAIz/XMYjv/fCgx0lnDEX4CbzI\nUGoz/bME4R721YRyXoutJ0h14/cGrt/TEn/TMI0xnISzJHr8VSlyBkQEdfO/W3LO\nqjs/UYq2Bz4+kJROJHreM+7d5hiIWLzLBlyI8cSU92ySmHECQQDwju2SoRu88kQP\n1qr4seZyKQa8DHTVyCoa6LtPLXyJs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pvWlv1alwhB2tsnLdazP62r1MO80vLyLunzGO+7WwCjEYlVaECgYEA+lQRFmbhKaPuAuXMtY31Fbga8nedka5TjnEV7+/kX+yowE2OlNujF+ZG8UTddTxAGv56yVNi/mjRlgD74j8z0eOsgvOq9mwbCrgLhLo51H9O/wAxtb+hBKtC5l50pBr4gER6d8W6EQNTSGojnMIaLXTkAZ5Qf6Z8e2HFVdOn0X0CgYEA7SSrTokwzukt5KldNu5ukyyd+C3D1i6orbg6qD73EP9CfNMfGSBn7dDv9wMSJH01+Ty+RgTROgtjGRDbMJWnfbdt/61NePr9ar5sb6Nbsf7/I0w7cZF5dsaFYgzaOfQYquzXPbLQHkpMT64bqpv/Mwy4F2lFvaYWY5fA4pC2uckCgYEAg75Ym9ybJaoTqky8ttQ2Jy8UZ4VSVQhVC0My02sCWwWXLlXi8y7An+Rec73Ve0yxREOn5WrQT6pkmzh7V/ABWrYi5WxODpCIjtSbo0fLBa3Wqle00b0/hdCITetqIa/cFs1zUrOqICgK3bKWeXqiAkhhcwSZwwSgwOKM04Wn7ZUCgYBvhHX2mbdVJfyJ8kc+hMOE/E9RHRxiBVEXWHJlGi8PVCqNDq8qHr4g7Mdbzprig+s0yKblwHAvrpkseWvKHiZEjVTyDipHgShY4TGXEigVvUd37uppTrLi8xpYcJjS9gH/px7VCdiq1d+q/MJP6coJ1KphgATm2UrgDMYNBWaYWQKBgEHRxrmER7btUF60/YgcqPHFc8RpYQB2ZZE0kyKGDqk2Data1XYUY6vsPAU28yRLAaWr/D2H17iyLkxP80VLm6QhifxCadv90Q/Wl1DFfOJQMW6avyQ0so6G0wFq/LJxaFK4iLXQn1RJnmTp6BYiJMmK2BhFbRzw8ssMoF6ad2rr",
// 请求地址 // 请求地址
url: "http://localhost:7071/prod/gw68uy85", url: "http://localhost:8081",
}; };
// 业务参数 // 业务参数
let mut biz_model = HashMap::new(); let mut biz_model = HashMap::new();

@ -93,11 +93,7 @@ impl OpenClient {
all_params.insert("charset", "UTF-8".to_string()); all_params.insert("charset", "UTF-8".to_string());
all_params.insert("timestamp", Local::now().format("%Y-%m-%d %H:%M:%S").to_string()); all_params.insert("timestamp", Local::now().format("%Y-%m-%d %H:%M:%S").to_string());
all_params.insert("version", version.to_string()); all_params.insert("version", version.to_string());
all_params.insert("biz_content", serde_json::to_string(&request.get_base().biz_model).unwrap_or(String::from("{}")));
// 添加业务参数
for entry in &request.get_base().biz_model {
all_params.insert(entry.0, entry.1.to_string());
}
if !token.is_empty() { if !token.is_empty() {
all_params.insert("app_auth_token", token.to_string()); all_params.insert("app_auth_token", token.to_string());

@ -0,0 +1,63 @@
package com.gitee.sop.test;
import com.alibaba.fastjson.JSON;
import com.gitee.sop.test.alipay.AlipaySignature;
import org.junit.Test;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
/**
* 接收数组
*/
public class ArrayTest extends TestBase {
String url = "http://localhost:8081";
String appId = "2019032617262200001";
// 平台提供的私钥
String privateKey = "MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCXJv1pQFqWNA/++OYEV7WYXwexZK/J8LY1OWlP9X0T6wHFOvxNKRvMkJ5544SbgsJpVcvRDPrcxmhPbi/sAhdO4x2PiPKIz9Yni2OtYCCeaiE056B+e1O2jXoLeXbfi9fPivJZkxH/tb4xfLkH3bA8ZAQnQsoXA0SguykMRZntF0TndUfvDrLqwhlR8r5iRdZLB6F8o8qXH6UPDfNEnf/K8wX5T4EB1b8x8QJ7Ua4GcIUqeUxGHdQpzNbJdaQvoi06lgccmL+PHzminkFYON7alj1CjDN833j7QMHdPtS9l7B67fOU/p2LAAkPMtoVBfxQt9aFj7B8rEhGCz02iJIBAgMBAAECggEARqOuIpY0v6WtJBfmR3lGIOOokLrhfJrGTLF8CiZMQha+SRJ7/wOLPlsH9SbjPlopyViTXCuYwbzn2tdABigkBHYXxpDV6CJZjzmRZ+FY3S/0POlTFElGojYUJ3CooWiVfyUMhdg5vSuOq0oCny53woFr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@Test
public void testGet() throws Exception {
// 公共请求参数
Map<String, String> params = new HashMap<String, String>();
params.put("app_id", appId);
params.put("method", "story.listparam");
params.put("format", "json");
params.put("charset", "utf-8");
params.put("sign_type", "RSA2");
params.put("timestamp", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
params.put("version", "1.0");
// 业务参数
String bizContent = "{\n" +
" \"name\": \"jim\",\n" +
" \"list\": [{\n" +
" \"age\": 22,\n" +
" \"name\": \"jim\",\n" +
" \"address\": \"xx\"\n" +
" }]\n" +
"}";
params.put("biz_content", JSON.toJSONString(JSON.parseObject(bizContent)));
String content = AlipaySignature.getSignContent(params);
String sign = AlipaySignature.rsa256Sign(content, privateKey, "utf-8");
params.put("sign", sign);
System.out.println("----------- 请求信息 -----------");
System.out.println("请求参数:" + buildParamQuery(params));
System.out.println("商户秘钥:" + privateKey);
System.out.println("待签名内容:" + content);
System.out.println("签名(sign):" + sign);
System.out.println("URL参数:" + buildUrlQuery(params));
System.out.println("----------- 返回结果 -----------");
String responseData = postJson(url, params);// 发送请求
System.out.println(responseData);
}
}
Loading…
Cancel
Save