From 0e730c9bd662e84ec90f260a80bd69c8738289dd Mon Sep 17 00:00:00 2001 From: WangXu10 Date: Thu, 21 Nov 2024 17:03:22 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=8E=A5=E5=8F=A3=E6=B5=8B=E8=AF=95):=20?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=9C=BA=E6=99=AF=E6=89=A7=E8=A1=8C=E6=97=B6?= =?UTF-8?q?=E5=A4=84=E7=90=86=E7=8E=AF=E5=A2=83=E7=9A=84HTTP=E5=8C=B9?= =?UTF-8?q?=E9=85=8D=E8=A7=84=E5=88=99=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../scenario/ApiScenarioRunService.java | 25 ++++++++++++------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/backend/services/api-test/src/main/java/io/metersphere/api/service/scenario/ApiScenarioRunService.java b/backend/services/api-test/src/main/java/io/metersphere/api/service/scenario/ApiScenarioRunService.java index e6432756b4..2ddc963612 100644 --- a/backend/services/api-test/src/main/java/io/metersphere/api/service/scenario/ApiScenarioRunService.java +++ b/backend/services/api-test/src/main/java/io/metersphere/api/service/scenario/ApiScenarioRunService.java @@ -7,6 +7,9 @@ import io.metersphere.api.controller.result.ApiResultCode; import io.metersphere.api.domain.*; import io.metersphere.api.dto.*; import io.metersphere.api.dto.debug.ApiResourceRunRequest; +import io.metersphere.api.dto.definition.ApiModuleDTO; +import io.metersphere.api.dto.definition.EnvApiModuleRequest; +import io.metersphere.api.dto.definition.EnvApiTreeDTO; import io.metersphere.api.dto.request.MsScenario; import io.metersphere.api.dto.request.controller.MsScriptElement; import io.metersphere.api.dto.request.http.MsHTTPElement; @@ -937,16 +940,20 @@ public class ApiScenarioRunService { // 获取勾选了包含子模块的模块ID HttpConfigModuleMatchRule moduleMatchRule = httpConfig.getModuleMatchRule(); List selectModules = moduleMatchRule.getModules(); - List containChildModuleIds = selectModules.stream() - .filter(SelectModule::getContainChildModule) - .map(SelectModule::getModuleId) - .toList(); - // 查询子模块ID, 并去重 - Set moduleIds = apiDefinitionModuleService.getModuleIdsByParentIds(containChildModuleIds) - .stream() - .collect(Collectors.toSet()); - selectModules.forEach(selectModule -> moduleIds.add(selectModule.getModuleId())); + EnvApiModuleRequest envApiModuleRequest = new EnvApiModuleRequest(); + envApiModuleRequest.setProjectId(envInfoDTO.getProjectId()); + List apiModuleDTOS = selectModules.stream().map(selectModule -> { + ApiModuleDTO apiModuleDTO = new ApiModuleDTO(); + apiModuleDTO.setModuleId(selectModule.getModuleId()); + apiModuleDTO.setContainChildModule(selectModule.getContainChildModule()); + return apiModuleDTO; + }).toList(); + envApiModuleRequest.setSelectedModules(apiModuleDTOS); + EnvApiTreeDTO envApiTreeDTO = apiDefinitionModuleService.envTree(envApiModuleRequest); + List selectedModules = envApiTreeDTO.getSelectedModules(); + List moduleIds = selectedModules.stream().map(ApiModuleDTO::getModuleId).toList(); + // 重新设置选中的模块ID moduleMatchRule.setModules(null);