refactor(测试计划): 优化接口列表返回值&查询sql

This commit is contained in:
WangXu10 2024-06-17 11:12:42 +08:00 committed by Craftsman
parent 12cda645a4
commit d083774987
5 changed files with 9 additions and 3 deletions

View File

@ -67,4 +67,7 @@ public class TestPlanApiScenarioPageResponse implements Serializable {
@Schema(description = "状态") @Schema(description = "状态")
private String status; private String status;
@Schema(description = "场景用例的id")
private String apiScenarioId;
} }

View File

@ -69,7 +69,7 @@ public interface ExtTestPlanApiCaseMapper {
List<TestPlanApiCase> getApiCaseExecuteInfoByIds(@Param("ids") List<String> ids); List<TestPlanApiCase> getApiCaseExecuteInfoByIds(@Param("ids") List<String> ids);
List<ApiTestCase> selectApiCaseByDefinitionIds(@Param("ids") List<String> ids, @Param("isRepeat") boolean isRepeat); List<ApiTestCase> selectApiCaseByDefinitionIds(@Param("ids") List<String> ids, @Param("isRepeat") boolean isRepeat, @Param("testPlanId") String testPlanId);
List<TestPlanApiCase> getSelectIdAndCollectionId(@Param("request") TestPlanApiCaseBatchRequest request); List<TestPlanApiCase> getSelectIdAndCollectionId(@Param("request") TestPlanApiCaseBatchRequest request);
} }

View File

@ -702,6 +702,7 @@
api_case_id api_case_id
FROM FROM
test_plan_api_case test_plan_api_case
where test_plan_api_case.test_plan_id = #{testPlanId}
) )
</if> </if>
</select> </select>

View File

@ -93,6 +93,7 @@
api_scenario.project_id, api_scenario.project_id,
api_scenario.create_user, api_scenario.create_user,
api_scenario.status, api_scenario.status,
api_scenario.id as apiScenarioId,
test_plan_api_scenario.create_time, test_plan_api_scenario.create_time,
test_plan_api_scenario.environment_id, test_plan_api_scenario.environment_id,
api_scenario.module_id, api_scenario.module_id,

View File

@ -551,7 +551,7 @@ public class TestPlanApiCaseService extends TestPlanResourceService {
if (CollectionUtils.isNotEmpty(apiCaseList)) { if (CollectionUtils.isNotEmpty(apiCaseList)) {
List<String> ids = apiCaseList.stream().flatMap(item -> item.getIds().stream()).toList(); List<String> ids = apiCaseList.stream().flatMap(item -> item.getIds().stream()).toList();
boolean isRepeat = testPlanConfigService.isRepeatCase(testPlan.getId()); boolean isRepeat = testPlanConfigService.isRepeatCase(testPlan.getId());
List<ApiTestCase> apiTestCaseList = extTestPlanApiCaseMapper.selectApiCaseByDefinitionIds(ids, isRepeat); List<ApiTestCase> apiTestCaseList = extTestPlanApiCaseMapper.selectApiCaseByDefinitionIds(ids, isRepeat, testPlan.getId());
apiCaseList.forEach(apiCase -> { apiCaseList.forEach(apiCase -> {
List<String> apiCaseIds = apiCase.getIds(); List<String> apiCaseIds = apiCase.getIds();
if (CollectionUtils.isNotEmpty(apiCaseIds)) { if (CollectionUtils.isNotEmpty(apiCaseIds)) {
@ -684,9 +684,10 @@ public class TestPlanApiCaseService extends TestPlanResourceService {
/** /**
* 预生成用例的执行报告 * 预生成用例的执行报告
*
* @return * @return
*/ */
public ApiTestCaseRecord initApiReport(ApiTestCase apiTestCase, TestPlanApiCase testPlanApiCase, String reportId, ApiRunModeConfigDTO runModeConfig, String userId) { public ApiTestCaseRecord initApiReport(ApiTestCase apiTestCase, TestPlanApiCase testPlanApiCase, String reportId, ApiRunModeConfigDTO runModeConfig, String userId) {
// 初始化报告 // 初始化报告
ApiReport apiReport = apiTestCaseService.getApiReport(apiTestCase, reportId, runModeConfig.getPoolId(), userId); ApiReport apiReport = apiTestCaseService.getApiReport(apiTestCase, reportId, runModeConfig.getPoolId(), userId);
apiReport.setEnvironmentId(runModeConfig.getEnvironmentId()); apiReport.setEnvironmentId(runModeConfig.getEnvironmentId());