fix(系统设置): 配额检查

This commit is contained in:
shiziyuan9527 2022-04-15 16:54:59 +08:00 committed by 刘瑞斌
parent 69efcbbedd
commit 05b76d1570
3 changed files with 25 additions and 4 deletions

View File

@ -74,5 +74,10 @@ public class TestResourcePoolController {
return testResourcePoolService.listValidQuotaResourcePools();
}
@GetMapping("/list/quota/ws/valid/{workspaceId}")
public List<TestResourcePoolDTO> listWsValidQuotaResourcePools(@PathVariable String workspaceId) {
return testResourcePoolService.listWsValidQuotaResourcePools(workspaceId);
}
}

View File

@ -36,6 +36,13 @@ public interface QuotaService {
*/
Set<String> getQuotaResourcePools();
/**
* 工作空间下被限制使用的资源池
* @param workspaceId 工作空间ID
* @return 资源池名称Set
*/
Set<String> getQuotaWsResourcePools(String workspaceId);
/**
* 检查工作空间项目数量配额
* @param workspaceId 工作空间ID

View File

@ -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<TestResourcePoolDTO> listWsValidQuotaResourcePools(String workspaceId) {
QuotaService quotaService = CommonBeanFactory.getBean(QuotaService.class);
List<TestResourcePoolDTO> list = listValidResourcePools();
if (quotaService != null) {
Set<String> pools = quotaService.getQuotaWsResourcePools(workspaceId);
if (!pools.isEmpty()) {
return list.stream().filter(pool -> pools.contains(pool.getId())).collect(Collectors.toList());
}
}
return list;
}
}