diff --git a/backend/services/api-test/src/main/java/io/metersphere/api/dto/definition/ApiModuleDTO.java b/backend/services/api-test/src/main/java/io/metersphere/api/dto/definition/ApiModuleDTO.java index 3ab79ef3f8..e7c6585cbc 100644 --- a/backend/services/api-test/src/main/java/io/metersphere/api/dto/definition/ApiModuleDTO.java +++ b/backend/services/api-test/src/main/java/io/metersphere/api/dto/definition/ApiModuleDTO.java @@ -1,14 +1,11 @@ package io.metersphere.api.dto.definition; +import io.metersphere.project.dto.environment.http.SelectModule; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; @Data -public class ApiModuleDTO { - @Schema(description = "模块ID") - private String id; - @Schema(description = "id的状态 None:手动选 Current:选中当前 All:全选中") - private String status; +public class ApiModuleDTO extends SelectModule { @Schema(description = "是否禁用") private Boolean disabled = false; } diff --git a/backend/services/api-test/src/main/java/io/metersphere/api/service/definition/ApiDefinitionModuleService.java b/backend/services/api-test/src/main/java/io/metersphere/api/service/definition/ApiDefinitionModuleService.java index 3ee11a4ee9..d3807850e6 100644 --- a/backend/services/api-test/src/main/java/io/metersphere/api/service/definition/ApiDefinitionModuleService.java +++ b/backend/services/api-test/src/main/java/io/metersphere/api/service/definition/ApiDefinitionModuleService.java @@ -1,7 +1,6 @@ package io.metersphere.api.service.definition; import com.github.pagehelper.PageHelper; -import io.metersphere.api.constants.ModuleStatus; import io.metersphere.api.domain.*; import io.metersphere.api.dto.debug.ApiTreeNode; import io.metersphere.api.dto.debug.ModuleCreateRequest; @@ -23,6 +22,7 @@ import io.metersphere.system.dto.sdk.request.NodeMoveRequest; import io.metersphere.system.uid.IDGenerator; import jakarta.annotation.Resource; import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.BooleanUtils; import org.apache.commons.lang3.StringUtils; import org.apache.ibatis.session.ExecutorType; import org.apache.ibatis.session.SqlSession; @@ -307,7 +307,7 @@ public class ApiDefinitionModuleService extends ModuleTreeService { List currentModules = new ArrayList<>(); if (CollectionUtils.isNotEmpty(selectedModules)) { //将选中的模块id转换为Map 方便后面的查询 key为id - Map selectedModuleMap = selectedModules.stream().collect(Collectors.toMap(ApiModuleDTO::getId, apiModuleDTO -> apiModuleDTO)); + Map selectedModuleMap = selectedModules.stream().collect(Collectors.toMap(ApiModuleDTO::getModuleId, apiModuleDTO -> apiModuleDTO)); getAllModuleIds(baseTreeNodes, currentModules, selectedModuleMap); } envApiTreeDTO.setSelectedModules(currentModules); @@ -318,7 +318,7 @@ public class ApiDefinitionModuleService extends ModuleTreeService { baseTreeNodes.forEach(baseTreeNode -> { if (selectedModuleMap.containsKey(baseTreeNode.getId())) { ApiModuleDTO apiModuleDTO = selectedModuleMap.get(baseTreeNode.getId()); - if (StringUtils.equals(apiModuleDTO.getStatus(), ModuleStatus.All.name())) { + if (BooleanUtils.isTrue(apiModuleDTO.getContainChildModule())) { currentModules.add(apiModuleDTO); if (CollectionUtils.isNotEmpty(baseTreeNode.getChildren())) { setChildren(baseTreeNode.getChildren(), currentModules); @@ -336,8 +336,8 @@ public class ApiDefinitionModuleService extends ModuleTreeService { public void setChildren(List baseTreeNodes, List currentModules) { baseTreeNodes.forEach(baseTreeNode -> { ApiModuleDTO children = new ApiModuleDTO(); - children.setId(baseTreeNode.getId()); - children.setStatus(ModuleStatus.All.name()); + children.setModuleId(baseTreeNode.getId()); + children.setContainChildModule(true); children.setDisabled(true); currentModules.add(children); if (CollectionUtils.isNotEmpty(baseTreeNode.getChildren())) { diff --git a/backend/services/api-test/src/test/java/io/metersphere/api/controller/ApiDefinitionModuleControllerTests.java b/backend/services/api-test/src/test/java/io/metersphere/api/controller/ApiDefinitionModuleControllerTests.java index 2c357cef06..73903c5725 100644 --- a/backend/services/api-test/src/test/java/io/metersphere/api/controller/ApiDefinitionModuleControllerTests.java +++ b/backend/services/api-test/src/test/java/io/metersphere/api/controller/ApiDefinitionModuleControllerTests.java @@ -916,26 +916,26 @@ public class ApiDefinitionModuleControllerTests extends BaseTest { BaseTreeNode a1a1Node = getNodeByName(baseTreeNodes, "500-test-root-20"); assert a1a1Node != null; ApiModuleDTO apiModuleDTO = new ApiModuleDTO(); - apiModuleDTO.setId(a1a1Node.getId()); - apiModuleDTO.setStatus("None"); + apiModuleDTO.setModuleId(a1a1Node.getId()); + apiModuleDTO.setContainChildModule(false); apiModuleDTOS.add(apiModuleDTO); BaseTreeNode a40Node = getNodeByName(baseTreeNodes, "500-test-root-40"); assert a40Node != null; apiModuleDTO = new ApiModuleDTO(); - apiModuleDTO.setId(a40Node.getId()); - apiModuleDTO.setStatus("All"); + apiModuleDTO.setModuleId(a40Node.getId()); + apiModuleDTO.setContainChildModule(true); apiModuleDTOS.add(apiModuleDTO); BaseTreeNode a50Node = getNodeByName(baseTreeNodes, "500-test-root-50"); assert a50Node != null; apiModuleDTO = new ApiModuleDTO(); - apiModuleDTO.setId(a50Node.getId()); - apiModuleDTO.setStatus("Current"); + apiModuleDTO.setModuleId(a50Node.getId()); + apiModuleDTO.setContainChildModule(false); apiModuleDTOS.add(apiModuleDTO); BaseTreeNode a100Node = getNodeByName(baseTreeNodes, "500-test-root-100"); assert a100Node != null; apiModuleDTO = new ApiModuleDTO(); - apiModuleDTO.setId(a100Node.getId()); - apiModuleDTO.setStatus("All"); + apiModuleDTO.setModuleId(a100Node.getId()); + apiModuleDTO.setContainChildModule(true); apiModuleDTOS.add(apiModuleDTO); result = this.requestPostWithOkAndReturn("/api/definition/module/env/tree", new EnvApiModuleRequest() {{ this.setProjectId(project.getId()); diff --git a/backend/services/project-management/src/main/java/io/metersphere/project/dto/environment/http/HttpConfigModuleMatchRule.java b/backend/services/project-management/src/main/java/io/metersphere/project/dto/environment/http/HttpConfigModuleMatchRule.java index 711d034d68..624641f4d0 100644 --- a/backend/services/project-management/src/main/java/io/metersphere/project/dto/environment/http/HttpConfigModuleMatchRule.java +++ b/backend/services/project-management/src/main/java/io/metersphere/project/dto/environment/http/HttpConfigModuleMatchRule.java @@ -14,7 +14,7 @@ import java.util.List; * @CreateTime: 2024-02-05 18:53 */ @Data -public class HttpConfigModuleMatchRule implements Serializable { +public class HttpConfigModuleMatchRule implements Serializable { @Serial private static final long serialVersionUID = 1L; @@ -22,11 +22,4 @@ public class HttpConfigModuleMatchRule implements Serializable { @Valid private List modules = new ArrayList<>(0); - @Data - public class SelectModule { - @Schema(description = "模块ID") - private String moduleId; - @Schema(description = "是否包含新增子模块") - private Boolean containChildModule = false; - } } diff --git a/backend/services/project-management/src/main/java/io/metersphere/project/dto/environment/http/SelectModule.java b/backend/services/project-management/src/main/java/io/metersphere/project/dto/environment/http/SelectModule.java new file mode 100644 index 0000000000..180d77388f --- /dev/null +++ b/backend/services/project-management/src/main/java/io/metersphere/project/dto/environment/http/SelectModule.java @@ -0,0 +1,12 @@ +package io.metersphere.project.dto.environment.http; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +@Data +public class SelectModule { + @Schema(description = "模块ID") + private String moduleId; + @Schema(description = "是否包含新增子模块") + private Boolean containChildModule = false; +}