diff --git a/backend/src/main/java/io/metersphere/api/dto/automation/parse/ApiScenarioImportUtil.java b/backend/src/main/java/io/metersphere/api/dto/automation/parse/ApiScenarioImportUtil.java index d2684be30c..72cc6f6688 100644 --- a/backend/src/main/java/io/metersphere/api/dto/automation/parse/ApiScenarioImportUtil.java +++ b/backend/src/main/java/io/metersphere/api/dto/automation/parse/ApiScenarioImportUtil.java @@ -171,7 +171,7 @@ public class ApiScenarioImportUtil { public static ApiDefinitionResult structureApiDefinitionByJson(int i,ApiDefinitionService apiDefinitionService,JSONObject object, String versionId, String projectId,ApiDefinitionMapper apiDefinitionMapper,MapdefinitionMap) { ApiDefinitionResult test = new ApiDefinitionResult(); - apiDefinitionService.checkQuota(); + apiDefinitionService.checkQuota(projectId); String protocal = object.getString("protocal"); if (StringUtils.equals(protocal, "DUBBO")) { test.setMethod("dubbo://"); diff --git a/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java b/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java index 6458165df3..c00c99ee5d 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java @@ -236,7 +236,7 @@ public class ApiAutomationService { } public ApiScenario create(SaveApiScenarioRequest request, List bodyFiles, List scenarioFiles) { - checkQuota(); + checkQuota(request.getProjectId()); request.setId(UUID.randomUUID().toString()); if (request.getScenarioDefinition() == null) { MsScenario msScenario = new MsScenario(); @@ -272,10 +272,10 @@ public class ApiAutomationService { return scenario; } - private void checkQuota() { + private void checkQuota(String projectId) { QuotaService quotaService = CommonBeanFactory.getBean(QuotaService.class); if (quotaService != null) { - quotaService.checkAPIAutomationQuota(); + quotaService.checkAPIAutomationQuota(projectId); } } diff --git a/backend/src/main/java/io/metersphere/api/service/ApiDefinitionService.java b/backend/src/main/java/io/metersphere/api/service/ApiDefinitionService.java index 78dc5e5ae5..e870ab3c95 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiDefinitionService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiDefinitionService.java @@ -319,7 +319,7 @@ public class ApiDefinitionService { } public ApiDefinitionWithBLOBs create(SaveApiDefinitionRequest request, List bodyFiles) { - checkQuota(); + checkQuota(request.getProjectId()); if (StringUtils.equals(request.getProtocol(), "DUBBO")) { request.setMethod("dubbo://"); } @@ -348,10 +348,10 @@ public class ApiDefinitionService { return getBLOBs(returnModel.getId()); } - public void checkQuota() { + public void checkQuota(String projectId) { QuotaService quotaService = CommonBeanFactory.getBean(QuotaService.class); if (quotaService != null) { - quotaService.checkAPIDefinitionQuota(); + quotaService.checkAPIDefinitionQuota(projectId); } } diff --git a/backend/src/main/java/io/metersphere/performance/service/PerformanceTestService.java b/backend/src/main/java/io/metersphere/performance/service/PerformanceTestService.java index 9fc6c7f2dd..cbe8932445 100644 --- a/backend/src/main/java/io/metersphere/performance/service/PerformanceTestService.java +++ b/backend/src/main/java/io/metersphere/performance/service/PerformanceTestService.java @@ -536,6 +536,7 @@ public class PerformanceTestService { RunTestPlanRequest checkRequest = new RunTestPlanRequest(); QuotaService quotaService = CommonBeanFactory.getBean(QuotaService.class); checkRequest.setLoadConfiguration(testReport.getLoadConfiguration()); + checkRequest.setProjectId(testReport.getProjectId()); if (quotaService != null) { quotaService.checkLoadTestQuota(checkRequest, false); String projectId = testReport.getProjectId(); diff --git a/backend/src/main/java/io/metersphere/service/QuotaService.java b/backend/src/main/java/io/metersphere/service/QuotaService.java index 7f08241e29..1de2e9bc21 100644 --- a/backend/src/main/java/io/metersphere/service/QuotaService.java +++ b/backend/src/main/java/io/metersphere/service/QuotaService.java @@ -17,12 +17,12 @@ public interface QuotaService { /** * api配额检查 */ - void checkAPIDefinitionQuota(); + void checkAPIDefinitionQuota(String projectId); /** * api配额检查 */ - void checkAPIAutomationQuota(); + void checkAPIAutomationQuota(String projectId); /** * 性能测试配额检查