fix(系统设置): 修复工作空间配额限制资源池后任然可以选择被禁用的资源池执行的缺陷

--bug=1026499 --user=王孝刚
【项目管理】设置过项目默认资源池1后,再设置工作空间可用资源池不能用资源池1,项目资源池还能使用资源池1
https://www.tapd.cn/55049933/s/1376951
This commit is contained in:
wxg0103 2023-05-30 11:34:44 +08:00 committed by fit2-zhao
parent 0614b47c14
commit 132bad7ac3
1 changed files with 12 additions and 0 deletions

View File

@ -17,15 +17,18 @@ import io.metersphere.quota.dto.QuotaConstants;
import io.metersphere.quota.dto.QuotaResult;
import jakarta.annotation.Resource;
import org.apache.commons.lang3.BooleanUtils;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
import java.util.Arrays;
import java.util.List;
import java.util.UUID;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicReference;
import java.util.stream.Collectors;
/**
* Quota project_id workspace_id 不同时存在
@ -62,6 +65,15 @@ public class QuotaManagementService {
}
String workspaceGlobalQuotaId = getWorkspaceGlobalQuotaId(workspaceId);
Quota quota = quotaMapper.selectByPrimaryKey(workspaceGlobalQuotaId);
Quota workspaceQuota = getWorkspaceQuota(workspaceId);
if (ObjectUtils.isNotEmpty(workspaceQuota) && ObjectUtils.isNotEmpty(quota) && StringUtils.isNotBlank(workspaceQuota.getResourcePool())) {
List<String> works = Arrays.asList(workspaceQuota.getResourcePool().split(","));
List<String> projects = Arrays.asList(quota.getResourcePool().split(","));
List<String> intersection = works.stream()
.filter(projects::contains)
.collect(Collectors.toList());
quota.setResourcePool(String.join(",", intersection));
}
if (quota == null) {
quota = new Quota();
quota.setId(workspaceGlobalQuotaId);