|
@@ -28,6 +28,7 @@ public class ApiClient {
|
|
// "mobile": "13812345678",
|
|
// "mobile": "13812345678",
|
|
// "nowDate": "2025-03-29"
|
|
// "nowDate": "2025-03-29"
|
|
|
|
|
|
|
|
+// private static final String APPKEY = "appKey001";
|
|
private static final String Api1_URL = "http://127.0.0.1:8080/api/api1";
|
|
private static final String Api1_URL = "http://127.0.0.1:8080/api/api1";
|
|
private static final String Api2_URL = "http://127.0.0.1:8080/api/api2";
|
|
private static final String Api2_URL = "http://127.0.0.1:8080/api/api2";
|
|
public static void main(String[] args) {
|
|
public static void main(String[] args) {
|
|
@@ -41,14 +42,15 @@ public class ApiClient {
|
|
// "nowDate": "2025-03-29"
|
|
// "nowDate": "2025-03-29"
|
|
System.out.println("接口一");
|
|
System.out.println("接口一");
|
|
String appId = "APP123";
|
|
String appId = "APP123";
|
|
- String reqTime = "1679999999";
|
|
|
|
|
|
+ String reqTime = System.currentTimeMillis()+"";
|
|
String goodsId = "GOODS001";
|
|
String goodsId = "GOODS001";
|
|
Integer amount = 2;
|
|
Integer amount = 2;
|
|
Double price = 99.9;
|
|
Double price = 99.9;
|
|
String mobile = "13812345678";
|
|
String mobile = "13812345678";
|
|
String nowDate = DateUtil.format(new Date(), "yyyy-MM-dd");
|
|
String nowDate = DateUtil.format(new Date(), "yyyy-MM-dd");
|
|
String reqId = "reqId001";
|
|
String reqId = "reqId001";
|
|
- String appKey = "appKey001";
|
|
|
|
|
|
+ String appKey = AppKey.appkey;
|
|
|
|
+// String appKey = "111";
|
|
String sign = DigestUtil.md5Hex((appId+goodsId+reqId+reqTime+appKey).getBytes());
|
|
String sign = DigestUtil.md5Hex((appId+goodsId+reqId+reqTime+appKey).getBytes());
|
|
Map<String, Object> map = new HashMap<>();
|
|
Map<String, Object> map = new HashMap<>();
|
|
map.put("appId", appId);
|
|
map.put("appId", appId);
|
|
@@ -66,6 +68,14 @@ public class ApiClient {
|
|
System.out.println(response.body());
|
|
System.out.println(response.body());
|
|
System.out.println("----------------------------------------------");
|
|
System.out.println("----------------------------------------------");
|
|
System.out.println("接口二");
|
|
System.out.println("接口二");
|
|
|
|
+ HttpRequest response2 = HttpRequest.get(Api2_URL).header("reqId", reqId);
|
|
|
|
+ for (Map.Entry<String, Object> entry : map.entrySet()) {
|
|
|
|
+ response2 = response2.form(entry.getKey(), entry.getValue());
|
|
|
|
+ }
|
|
|
|
+ HttpResponse execute = response2.execute();
|
|
|
|
+ System.out.println(execute.getStatus());
|
|
|
|
+ System.out.println(execute.body());
|
|
|
|
+ System.out.println("----------------------------------------------");
|
|
String url = Api2_URL + "?appId=" + appId +
|
|
String url = Api2_URL + "?appId=" + appId +
|
|
"&sign=" + sign +
|
|
"&sign=" + sign +
|
|
"&reqTime=" + reqTime +
|
|
"&reqTime=" + reqTime +
|