From ab31ec2fe969cb249a40e400f743aaa8d1602f8e Mon Sep 17 00:00:00 2001 From: guoyuqi Date: Tue, 29 Mar 2022 17:34:07 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=8E=A5=E5=8F=A3=E6=B5=8B=E8=AF=95):=20?= =?UTF-8?q?=E5=9C=BA=E6=99=AF=E5=AF=BC=E5=85=A5=E5=88=9B=E5=BB=BA=E4=BA=BA?= =?UTF-8?q?=E9=BB=98=E8=AE=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --user=郭雨琦 场景导入创建人默认 查case也要过滤 --- .../dto/automation/parse/ApiScenarioImportUtil.java | 10 +++++----- .../metersphere/api/service/ApiAutomationService.java | 3 +++ 2 files changed, 8 insertions(+), 5 deletions(-) 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 bbb0cefb93..a0d4085805 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 @@ -116,9 +116,7 @@ public class ApiScenarioImportUtil { } } - private static ApiDefinition getApiDefinitionResult(JSONObject object, ApiDefinitionService apiDefinitionService,MapdefinitionMap) { - CheckPermissionService checkPermissionService = CommonBeanFactory.getBean(CheckPermissionService.class); - Set userRelatedProjectIds = checkPermissionService.getUserRelatedProjectIds(); + private static ApiDefinition getApiDefinitionResult(JSONObject object, ApiDefinitionService apiDefinitionService,MapdefinitionMap,Set userRelatedProjectIds) { List projectIds = new ArrayList<>(userRelatedProjectIds); ApiDefinitionExample apiDefinitionExample = new ApiDefinitionExample(); apiDefinitionExample.createCriteria() @@ -147,8 +145,10 @@ public class ApiScenarioImportUtil { ApiTestCaseService testCaseService = CommonBeanFactory.getBean(ApiTestCaseService.class); ApiDefinitionService apiDefinitionService = CommonBeanFactory.getBean(ApiDefinitionService.class); ApiTestCaseWithBLOBs bloBs = testCaseService.get(object.getString("id")); - if (bloBs == null) { - ApiDefinition apiDefinition = getApiDefinitionResult(object,apiDefinitionService,definitionMap); + CheckPermissionService checkPermissionService = CommonBeanFactory.getBean(CheckPermissionService.class); + Set userRelatedProjectIds = checkPermissionService.getUserRelatedProjectIds(); + if (bloBs == null||!userRelatedProjectIds.contains(bloBs.getProjectId())) { + ApiDefinition apiDefinition = getApiDefinitionResult(object,apiDefinitionService,definitionMap,userRelatedProjectIds); if(apiDefinition!=null){ if(MapUtils.isNotEmpty(definitionMap)||definitionMap.size()==0){ structureCaseByJson(i,object,testCaseService, apiDefinition,apiTestCaseMapper); 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 8d9712671c..ed113f18e5 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java @@ -1299,6 +1299,9 @@ public class ApiAutomationService { if (StringUtils.isBlank(item.getId())) { item.setId(UUID.randomUUID().toString()); } + item.setCreateUser(SessionUtils.getUserId()); + item.setUserId(SessionUtils.getUserId()); + item.setPrincipal(SessionUtils.getUserId()); // 导入之后刷新latest importCreate(item, batchMapper, extApiScenarioMapper, request,apiTestCaseMapper,apiDefinitionMapper); if (i % 300 == 0) {