Commit b66dd431 authored by wdy's avatar wdy

Merge branch 'wangdingyi' into 'dev'

调用接口

See merge request !401
parents 169b0865 a817d8c0
package com.ruoyi;
import cn.hutool.core.io.FileUtil;
import cn.hutool.core.io.IoUtil;
import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpResponse;
import cn.hutool.http.HttpUtil;
import com.alibaba.fastjson2.JSONObject;
import org.junit.jupiter.api.Test;
import java.util.HashMap;
import java.util.Map;
public class TestDownload {
@Test
public void test() {
try {
// 直接使用URL作为POST请求的目标,假设所有需要的信息已包含在URL中
HttpResponse response = HttpRequest.post("https://10.12.48.78:8090/api/project/download" + "/fd40de37-9c57-4597-8f74-d0754dfa17b2")
// 如果需要添加特定的请求头,如认证信息,可以在这里添加
//.header("Authorization", "Bearer your_token_here")
.execute();
// 检查响应是否成功
if (response.isOk()) {
System.out.println("response = " + response);
// 获取文件名,这里简化处理,实际情况可能需要从响应头中解析(如Content-Disposition)
// String fileName = "downloaded_file_from_post.zip";
//
// // 保存到本地
// FileUtil.writeBytes(IoUtil.readBytes(response.bodyStream()), FileUtil.file(fileName));
//
// System.out.println("文件下载成功:" + fileName);
} else {
System.err.println("下载失败,状态码:" + response.getStatus());
}
} catch (Exception e) {
e.printStackTrace();
}
//以post形式请求接口
// String result= HttpUtil.post("https://10.12.48.78:8090/api/project/download","/fd40de37-9c57-4597-8f74-d0754dfa17b2");
}
}
......@@ -28,7 +28,7 @@ public class TestRecordsTest {
public void test() {
Map<String, Object> map = new HashMap<>();
map.put("id", "project_items;27");
map.put("id", "5wU7nij8QomtoGMVhoxQjryw8hncJ");
map.put("verbose", "ALL");
//以post形式请求接口
......@@ -43,7 +43,7 @@ public class TestRecordsTest {
List<CaseResultVO> caseResultVOS = jsonObject.getList("case_result_list", CaseResultVO.class);
// 获取本地存储的列表
List<TestRecords> recordsList = testRecordsService.findByTaskId("project_items;29");
List<TestRecords> recordsList = testRecordsService.findByTaskId("5wU7nij8QomtoGMVhoxQjryw8hncJ");
List<TestRecords> list = new ArrayList<>();
if (caseResultVOS.size() != 0 && caseResultVOS != null) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment