This commit is contained in:
六如
2024-11-04 14:37:54 +08:00
parent d9a257ff23
commit 53a40a1cb4
14 changed files with 285 additions and 65 deletions

View File

@@ -179,6 +179,10 @@ public class Client {
private String url;
private String method;
private String version = DEFAULT_VERSION;
/**
* 回调地址
*/
private String notifyUrl;
private Map<String, Object> bizContent;
private HttpTool.HTTPMethod httpMethod;
private Map<String, String> header;
@@ -221,6 +225,17 @@ public class Client {
return this;
}
/**
* 设置notifyUrl
*
* @param notifyUrl notifyUrl
* @return 返回RequestBuilder
*/
public RequestBuilder notifyUrl(String notifyUrl) {
this.notifyUrl = notifyUrl;
return this;
}
/**
* 设置业务参数
*
@@ -392,6 +407,9 @@ public class Client {
params.put("charset", "utf-8");
params.put("sign_type", "RSA2");
params.put("timestamp", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
if (notifyUrl != null) {
params.put("notify_url", notifyUrl);
}
if (systemParam != null) {
params.putAll(systemParam);
}

View File

@@ -107,6 +107,25 @@ public class AllInOneTest extends TestBase {
client.execute(requestBuilder);
}
/**
* 多版本2.0
*/
public void testGet_v3() {
Client.RequestBuilder requestBuilder = new Client.RequestBuilder()
.method("story.get")
.version("3.0")
.notifyUrl("http://www.baidu.com")
.bizContent(new BizContent().add("id", "2").add("name", "葫芦娃2"))
.httpMethod(HttpTool.HTTPMethod.GET)
.callback((requestInfo, responseData) -> {
System.out.println(responseData);
JSONObject jsonObject = JSON.parseObject(responseData);
Assert.assertEquals("0", jsonObject.getString("code"));
});
client.execute(requestBuilder);
}
/**
* 测试是否有权限访问可在sop-admin中设置权限