fix(系统设置): 配额检查
This commit is contained in:
parent
69efcbbedd
commit
05b76d1570
|
@ -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);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -36,6 +36,13 @@ public interface QuotaService {
|
|||
*/
|
||||
Set<String> getQuotaResourcePools();
|
||||
|
||||
/**
|
||||
* 工作空间下被限制使用的资源池
|
||||
* @param workspaceId 工作空间ID
|
||||
* @return 资源池名称Set
|
||||
*/
|
||||
Set<String> getQuotaWsResourcePools(String workspaceId);
|
||||
|
||||
/**
|
||||
* 检查工作空间项目数量配额
|
||||
* @param workspaceId 工作空间ID
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue