diff --git a/backend/framework/plugin/plugin-platform-sdk/src/main/java/io/metersphere/plugin/platform/dto/response/PlatformDemandDTO.java b/backend/framework/plugin/plugin-platform-sdk/src/main/java/io/metersphere/plugin/platform/dto/response/PlatformDemandDTO.java index 2ce739a902..7824daaae5 100644 --- a/backend/framework/plugin/plugin-platform-sdk/src/main/java/io/metersphere/plugin/platform/dto/response/PlatformDemandDTO.java +++ b/backend/framework/plugin/plugin-platform-sdk/src/main/java/io/metersphere/plugin/platform/dto/response/PlatformDemandDTO.java @@ -36,6 +36,10 @@ public class PlatformDemandDTO { * 需求地址 */ private String demandUrl; + /** + * 已关联的需求要禁用 + */ + private boolean disabled; /** * 子需求集合 */ diff --git a/backend/services/case-management/src/main/java/io/metersphere/functional/mapper/ExtFunctionalCaseDemandMapper.java b/backend/services/case-management/src/main/java/io/metersphere/functional/mapper/ExtFunctionalCaseDemandMapper.java index 49d1078623..534ba3edcc 100644 --- a/backend/services/case-management/src/main/java/io/metersphere/functional/mapper/ExtFunctionalCaseDemandMapper.java +++ b/backend/services/case-management/src/main/java/io/metersphere/functional/mapper/ExtFunctionalCaseDemandMapper.java @@ -15,4 +15,7 @@ public interface ExtFunctionalCaseDemandMapper { List selectDemandByProjectId(@Param("projectId") String projectId, @Param("platform") String platform); + List selectDemandIdsByCaseId(@Param("caseId") String caseId, @Param("platform") String platform); + + } diff --git a/backend/services/case-management/src/main/java/io/metersphere/functional/mapper/ExtFunctionalCaseDemandMapper.xml b/backend/services/case-management/src/main/java/io/metersphere/functional/mapper/ExtFunctionalCaseDemandMapper.xml index 3ad9f9b5d6..fffea7b9f0 100644 --- a/backend/services/case-management/src/main/java/io/metersphere/functional/mapper/ExtFunctionalCaseDemandMapper.xml +++ b/backend/services/case-management/src/main/java/io/metersphere/functional/mapper/ExtFunctionalCaseDemandMapper.xml @@ -24,4 +24,10 @@ where functional_case.project_id = #{projectId} and functional_case_demand.demand_platform=#{platform} + + \ No newline at end of file diff --git a/backend/services/case-management/src/main/java/io/metersphere/functional/request/FunctionalThirdDemandPageRequest.java b/backend/services/case-management/src/main/java/io/metersphere/functional/request/FunctionalThirdDemandPageRequest.java index aef74b64d6..22b783b366 100644 --- a/backend/services/case-management/src/main/java/io/metersphere/functional/request/FunctionalThirdDemandPageRequest.java +++ b/backend/services/case-management/src/main/java/io/metersphere/functional/request/FunctionalThirdDemandPageRequest.java @@ -13,4 +13,8 @@ public class FunctionalThirdDemandPageRequest extends BasePageRequest { @NotBlank(message = "{case_review.project_id.not_blank}") private String projectId; + @Schema(description = "当前选择的用例Id", requiredMode = Schema.RequiredMode.REQUIRED) + @NotBlank(message = "{case_review.case_id.not_blank}") + private String caseId; + } diff --git a/backend/services/case-management/src/main/java/io/metersphere/functional/service/FunctionalCaseDemandService.java b/backend/services/case-management/src/main/java/io/metersphere/functional/service/FunctionalCaseDemandService.java index 0e89ced7d2..182ad0d5a6 100644 --- a/backend/services/case-management/src/main/java/io/metersphere/functional/service/FunctionalCaseDemandService.java +++ b/backend/services/case-management/src/main/java/io/metersphere/functional/service/FunctionalCaseDemandService.java @@ -349,6 +349,8 @@ public class FunctionalCaseDemandService { } public PluginPager pageDemand(FunctionalThirdDemandPageRequest request) { + String platformId = projectApplicationService.getDemandPlatformId(request.getProjectId()); + List demandIds = extFunctionalCaseDemandMapper.selectDemandIdsByCaseId(request.getCaseId(), platformId); DemandPageRequest demandPageRequest = new DemandPageRequest(); demandPageRequest.setQuery(StringUtils.replace(request.getKeyword(), "\\", "")); demandPageRequest.setFilter(request.getFilter()); @@ -356,6 +358,16 @@ public class FunctionalCaseDemandService { demandPageRequest.setPageSize(request.getPageSize()); demandPageRequest.setProjectConfig(projectApplicationService.getProjectDemandThirdPartConfig(request.getProjectId())); Platform platform = projectApplicationService.getPlatform(request.getProjectId(), false); - return platform.pageDemand(demandPageRequest); + PluginPager platformDemandDTOPluginPager = platform.pageDemand(demandPageRequest); + PlatformDemandDTO data = platformDemandDTOPluginPager.getData(); + List list = data.getList(); + for (PlatformDemandDTO.Demand demand : list) { + if (demandIds.contains(demand.getDemandId())) { + demand.setDisabled(true); + } + } + data.setList(list); + platformDemandDTOPluginPager.setData(data); + return platformDemandDTOPluginPager; } } diff --git a/backend/services/case-management/src/test/java/io/metersphere/functional/controller/FunctionalCaseDemandControllerTests.java b/backend/services/case-management/src/test/java/io/metersphere/functional/controller/FunctionalCaseDemandControllerTests.java index b5ac039c7f..3f0e9e16f7 100644 --- a/backend/services/case-management/src/test/java/io/metersphere/functional/controller/FunctionalCaseDemandControllerTests.java +++ b/backend/services/case-management/src/test/java/io/metersphere/functional/controller/FunctionalCaseDemandControllerTests.java @@ -666,12 +666,30 @@ public class FunctionalCaseDemandControllerTests extends BaseTest { functionalThirdDemandPageRequest.setProjectId("gyq_project-case-demand-test"); functionalThirdDemandPageRequest.setPageSize(10); functionalThirdDemandPageRequest.setCurrent(1); + functionalThirdDemandPageRequest.setCaseId("DEMAND_TEST_FUNCTIONAL_CASE_ID"); MvcResult mvcResultDemand= this.requestPostWithOkAndReturn(URL_DEMAND_PAGE_DEMAND, functionalThirdDemandPageRequest); PluginPager tableData = JSON.parseObject(JSON.toJSONString( JSON.parseObject(mvcResultDemand.getResponse().getContentAsString(StandardCharsets.UTF_8), ResultHolder.class).getData()), PluginPager.class); + FunctionalCaseDemand functionalCaseDemand = new FunctionalCaseDemand(); + functionalCaseDemand.setId("测试过滤ID"); + functionalCaseDemand.setDemandName("Test"); + functionalCaseDemand.setCaseId("DEMAND_TEST_FUNCTIONAL_CASE_ID"); + functionalCaseDemand.setDemandId("TES-1"); + functionalCaseDemand.setDemandUrl("http://localhost:57767/jira/software/projects/TES/issues/TES-1"); + functionalCaseDemand.setDemandPlatform("Metersphere"); + functionalCaseDemand.setUpdateUser("admin"); + functionalCaseDemand.setUpdateTime(System.currentTimeMillis()); + functionalCaseDemand.setWithParent(false); + functionalCaseDemand.setCreateUser("admin"); + functionalCaseDemand.setCreateTime(System.currentTimeMillis()); + functionalCaseDemand.setParent("NONE"); + functionalCaseDemandMapper.insert(functionalCaseDemand); + mvcResultDemand= this.requestPostWithOkAndReturn(URL_DEMAND_PAGE_DEMAND, functionalThirdDemandPageRequest); + tableData = JSON.parseObject(JSON.toJSONString( + JSON.parseObject(mvcResultDemand.getResponse().getContentAsString(StandardCharsets.UTF_8), ResultHolder.class).getData()), + PluginPager.class); - System.out.println(JSON.toJSONString(tableData)); } @Test