Commit 1ff7a1c2 authored by wdy's avatar wdy

Merge branch 'wangdingyi' into 'master'

获取所有测试用例编号

See merge request !12
parents d1fe7f04 3f9a9394
......@@ -103,4 +103,11 @@ public interface TestUseCaseService extends IService<TestUseCase> {
* @return
*/
NewTestUserCaseListResponse getCaseListNew(String request) throws IOException;
/**
* 获取测试用例编号数组(科恩)
* @param request
* @return
*/
List<SerialNumberResponse> getSerialNumberList(String request) throws IOException;
}
......@@ -408,6 +408,49 @@ public class TestUseCaseServiceImpl extends ServiceImpl<TestUseCaseMapper, TestU
return caseResponse;
}
@Override
public List<SerialNumberResponse> getSerialNumberList(String request) throws IOException {
List<SerialNumberResponse> serialNumberList = new ArrayList<>();
OkHttpClient client = new OkHttpClient().newBuilder().build();
MediaType mediaType = MediaType.parse("application/json");
// 创建请求体
RequestBody body = RequestBody.create(mediaType, "{\"query\":\"query regulationAllUseCases($offset:OffsetConnectionInput$name: String!){regulationByName(name:$name){items(offset:$offset){ nodes{id serialNumber requirements useCases{id customizedID description}}totalCount}}}\",\"variables\":"+ request +"}");
Request requestKE = new Request.Builder()
.url("http://10.12.48.80:8089/api/query")
.method("POST", body)
.addHeader("Content-Type", "application/json")
// TODO 连接
.addHeader("Authorization", "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjAsInRva2VuaWQiOjYxLCJ0eXBlIjoiYXBpIiwidXNlcm5hbWUiOiJhZG1pbiJ9.48Ggjx-FtOcecf73vAHn0XglwgLXZlfXxhXiLDHWWQE")
// .addHeader("Host", "10.12.48.80:8089")
// .addHeader("Origin", "http://10.12.48.80:8089")
// .addHeader("Referer", "http://10.12.48.80:8089/api/graphql/playground")
// .addHeader("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36")
.build();
Response response = client.newCall(requestKE).execute();
String string = response.body().string();
JSONObject jsonObject = JSONObject.parseObject(string);
// 获取测试用例
if (jsonObject.getJSONObject("data").getJSONObject("regulationByName") != null) {
List<StandardNewVO> list = jsonObject.getJSONObject("data").getJSONObject("regulationByName").getJSONObject("items").getList("nodes", StandardNewVO.class);
SerialNumberResponse numberResponse = new SerialNumberResponse();
for(StandardNewVO vo : list) {
for (UseCaseNewVO useCaseNewVO : vo.getUseCases()) {
numberResponse.setId(useCaseNewVO.getId());
numberResponse.setSerialNumber(vo.getSerialNumber());
serialNumberList.add(numberResponse);
}
}
}
return serialNumberList;
}
}
......
......@@ -153,4 +153,15 @@ public class TestUserCaseController extends BaseController{
}
@ApiOperation("获取测试用例编号数组(科恩)")
@Trace
@Tags({@Tag(key = "param", value = "arg[0]"), @Tag(key = "result", value = "returnedObj")})
@RequestMapping(method = RequestMethod.POST, value = "/getSerialNumberList", produces="application/json;charset=UTF-8")
public TableDataInfo<SerialNumberResponse> getSerialNumberList(@Validated @RequestBody String request) throws IOException {
List<SerialNumberResponse> list = testUseCaseService.getSerialNumberList(request);
return getDataTable(list);
}
}
package com.ruoyi.web.response;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@ApiModel(value = "SerialNumberResponse", description = "查询测试用例编号")
@Data
public class SerialNumberResponse {
@ApiModelProperty("用例id")
private String id;
@ApiModelProperty("用例编号")
private String serialNumber;
}
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