mirror of
https://gitee.com/durcframework/SOP.git
synced 2025-08-11 21:57:56 +08:00
4.2.2
This commit is contained in:
@@ -174,6 +174,8 @@ public class Client {
|
|||||||
public static class RequestBuilder {
|
public static class RequestBuilder {
|
||||||
private static final String DEFAULT_VERSION = "1.0";
|
private static final String DEFAULT_VERSION = "1.0";
|
||||||
|
|
||||||
|
private Map<String, String> systemParam;
|
||||||
|
|
||||||
private String url;
|
private String url;
|
||||||
private String method;
|
private String method;
|
||||||
private String version = DEFAULT_VERSION;
|
private String version = DEFAULT_VERSION;
|
||||||
@@ -277,6 +279,20 @@ public class Client {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加系统参数
|
||||||
|
* @param name 参数名
|
||||||
|
* @param value 参数值
|
||||||
|
* @return 返回RequestBuilder
|
||||||
|
*/
|
||||||
|
public RequestBuilder addSystemParam(String name, String value) {
|
||||||
|
if (systemParam == null) {
|
||||||
|
systemParam = new HashMap<>(8);
|
||||||
|
}
|
||||||
|
systemParam.put(name, value);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设置token
|
* 设置token
|
||||||
*
|
*
|
||||||
@@ -376,9 +392,14 @@ public class Client {
|
|||||||
params.put("charset", "utf-8");
|
params.put("charset", "utf-8");
|
||||||
params.put("sign_type", "RSA2");
|
params.put("sign_type", "RSA2");
|
||||||
params.put("timestamp", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
|
params.put("timestamp", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
|
||||||
|
if (systemParam != null) {
|
||||||
|
params.putAll(systemParam);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (bizContent != null) {
|
||||||
// 业务参数
|
// 业务参数
|
||||||
params.put("biz_content", JSON.toJSONString(bizContent == null ? Collections.emptyMap() : bizContent));
|
params.put("biz_content", JSON.toJSONString(bizContent));
|
||||||
|
}
|
||||||
|
|
||||||
if (!ignoreSign) {
|
if (!ignoreSign) {
|
||||||
String content = AlipaySignature.getSignContent(params);
|
String content = AlipaySignature.getSignContent(params);
|
||||||
|
@@ -353,6 +353,24 @@ public class AllInOneTest extends TestBase {
|
|||||||
client.execute(requestBuilder);
|
client.execute(requestBuilder);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 以get方式提交
|
||||||
|
*/
|
||||||
|
public void testBindParam() {
|
||||||
|
Client.RequestBuilder requestBuilder = new Client.RequestBuilder()
|
||||||
|
.method("story.param.bind")
|
||||||
|
.version("1.0")
|
||||||
|
.addSystemParam("id", "1")
|
||||||
|
.addSystemParam("name", "葫芦娃")
|
||||||
|
.httpMethod(HttpTool.HTTPMethod.GET)
|
||||||
|
.callback(((requestInfo, responseData) -> {
|
||||||
|
System.out.println(responseData);
|
||||||
|
Assert.assertTrue(responseData.contains("参数绑定:id:1, name:葫芦娃"));
|
||||||
|
}));
|
||||||
|
|
||||||
|
client.execute(requestBuilder);
|
||||||
|
}
|
||||||
|
|
||||||
static class BizContent extends HashMap<String, Object> {
|
static class BizContent extends HashMap<String, Object> {
|
||||||
public BizContent add(String key, Object value) {
|
public BizContent add(String key, Object value) {
|
||||||
this.put(key, value);
|
this.put(key, value);
|
||||||
|
Reference in New Issue
Block a user