From d60333c178f11c2cd0fe5dc36ed5ef095d6a06b9 Mon Sep 17 00:00:00 2001 From: WangXu10 Date: Fri, 2 Feb 2024 13:45:17 +0800 Subject: [PATCH] =?UTF-8?q?refactor(=E9=A1=B9=E7=9B=AE=E7=AE=A1=E7=90=86):?= =?UTF-8?q?=20=E4=BC=98=E5=8C=96=E5=BA=94=E7=94=A8=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E8=B5=84=E6=BA=90=E6=B1=A0=E4=B8=8B=E6=8B=89?= =?UTF-8?q?=E6=A1=86=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../project/service/ProjectService.java | 23 ++++--------------- 1 file changed, 4 insertions(+), 19 deletions(-) diff --git a/backend/services/project-management/src/main/java/io/metersphere/project/service/ProjectService.java b/backend/services/project-management/src/main/java/io/metersphere/project/service/ProjectService.java index 0fdec1412b..93c0e8b107 100644 --- a/backend/services/project-management/src/main/java/io/metersphere/project/service/ProjectService.java +++ b/backend/services/project-management/src/main/java/io/metersphere/project/service/ProjectService.java @@ -138,33 +138,18 @@ public class ProjectService { } private List getPoolIds(String projectId) { - List poolIds = new ArrayList<>(); ProjectTestResourcePoolExample example = new ProjectTestResourcePoolExample(); example.createCriteria().andProjectIdEqualTo(projectId); List projectPools = projectTestResourcePoolMapper.selectByExample(example); - if (CollectionUtils.isNotEmpty(projectPools)) { - return projectPools.stream().map(ProjectTestResourcePool::getTestResourcePoolId).toList(); - } - //判断项目所属组织是否关联了资源池 - Project project = projectMapper.selectByPrimaryKey(projectId); - TestResourcePoolOrganizationExample orgExample = new TestResourcePoolOrganizationExample(); - orgExample.createCriteria().andOrgIdEqualTo(project.getOrganizationId()); - List orgPools = testResourcePoolOrganizationMapper.selectByExample(orgExample); - if (CollectionUtils.isNotEmpty(orgPools)) { - poolIds.addAll(orgPools.stream().map(TestResourcePoolOrganization::getTestResourcePoolId).toList()); - } - //获取应用全部组织的资源池 - TestResourcePoolExample poolExample = new TestResourcePoolExample(); - poolExample.createCriteria().andAllOrgEqualTo(true).andEnableEqualTo(true).andDeletedEqualTo(false); - List testResourcePools = testResourcePoolMapper.selectByExample(poolExample); - poolIds.addAll(testResourcePools.stream().map(TestResourcePool::getId).toList()); - poolIds = poolIds.stream().distinct().filter(StringUtils::isNotBlank).toList(); - return poolIds; + return projectPools.stream().map(ProjectTestResourcePool::getTestResourcePoolId).toList(); } public List getPoolOptions(String projectId, String type) { checkProjectNotExist(projectId); List poolIds = getPoolIds(projectId); + if(CollectionUtils.isEmpty(poolIds)){ + return new ArrayList<>(); + } TestResourcePoolExample example = new TestResourcePoolExample(); TestResourcePoolExample.Criteria criteria = example.createCriteria(); criteria.andIdIn(poolIds).andEnableEqualTo(true).andDeletedEqualTo(false);