diff --git a/backend/src/main/java/io/metersphere/controller/TestResourcePoolController.java b/backend/src/main/java/io/metersphere/controller/TestResourcePoolController.java index 58b203de5d..c33bd0e6b0 100644 --- a/backend/src/main/java/io/metersphere/controller/TestResourcePoolController.java +++ b/backend/src/main/java/io/metersphere/controller/TestResourcePoolController.java @@ -74,5 +74,10 @@ public class TestResourcePoolController { return testResourcePoolService.listValidQuotaResourcePools(); } + @GetMapping("/list/quota/ws/valid/{workspaceId}") + public List listWsValidQuotaResourcePools(@PathVariable String workspaceId) { + return testResourcePoolService.listWsValidQuotaResourcePools(workspaceId); + } + } diff --git a/backend/src/main/java/io/metersphere/service/QuotaService.java b/backend/src/main/java/io/metersphere/service/QuotaService.java index 4d89bfc5d2..f56eabb6ab 100644 --- a/backend/src/main/java/io/metersphere/service/QuotaService.java +++ b/backend/src/main/java/io/metersphere/service/QuotaService.java @@ -36,6 +36,13 @@ public interface QuotaService { */ Set getQuotaResourcePools(); + /** + * 工作空间下被限制使用的资源池 + * @param workspaceId 工作空间ID + * @return 资源池名称Set + */ + Set getQuotaWsResourcePools(String workspaceId); + /** * 检查工作空间项目数量配额 * @param workspaceId 工作空间ID diff --git a/backend/src/main/java/io/metersphere/service/TestResourcePoolService.java b/backend/src/main/java/io/metersphere/service/TestResourcePoolService.java index 9a231c9269..f604177a17 100644 --- a/backend/src/main/java/io/metersphere/service/TestResourcePoolService.java +++ b/backend/src/main/java/io/metersphere/service/TestResourcePoolService.java @@ -28,10 +28,7 @@ import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; import java.lang.reflect.InvocationTargetException; -import java.util.ArrayList; -import java.util.List; -import java.util.Set; -import java.util.UUID; +import java.util.*; import java.util.stream.Collectors; import static io.metersphere.commons.constants.ResourceStatusEnum.*; @@ -288,4 +285,16 @@ public class TestResourcePoolService { } return null; } + + public List listWsValidQuotaResourcePools(String workspaceId) { + QuotaService quotaService = CommonBeanFactory.getBean(QuotaService.class); + List list = listValidResourcePools(); + if (quotaService != null) { + Set pools = quotaService.getQuotaWsResourcePools(workspaceId); + if (!pools.isEmpty()) { + return list.stream().filter(pool -> pools.contains(pool.getId())).collect(Collectors.toList()); + } + } + return list; + } }