diff --git a/backend/services/api-test/src/main/java/io/metersphere/api/mapper/ExtApiTestCaseMapper.xml b/backend/services/api-test/src/main/java/io/metersphere/api/mapper/ExtApiTestCaseMapper.xml index e993f9d683..4c069e1959 100644 --- a/backend/services/api-test/src/main/java/io/metersphere/api/mapper/ExtApiTestCaseMapper.xml +++ b/backend/services/api-test/src/main/java/io/metersphere/api/mapper/ExtApiTestCaseMapper.xml @@ -373,6 +373,7 @@ and ( atc.name like concat('%', #{request.condition.keyword},'%') or atc.num like concat('%', #{request.condition.keyword},'%') + or a.path like concat('%', #{request.condition.keyword},'%') or atc.tags like concat('%', #{request.condition.keyword},'%') ) diff --git a/backend/services/api-test/src/main/java/io/metersphere/api/service/definition/ApiDefinitionImportUtilService.java b/backend/services/api-test/src/main/java/io/metersphere/api/service/definition/ApiDefinitionImportUtilService.java index ffa973bc50..ffefcdbe45 100644 --- a/backend/services/api-test/src/main/java/io/metersphere/api/service/definition/ApiDefinitionImportUtilService.java +++ b/backend/services/api-test/src/main/java/io/metersphere/api/service/definition/ApiDefinitionImportUtilService.java @@ -156,16 +156,18 @@ public class ApiDefinitionImportUtilService { //如果导入的时候选择了模块,需要把所有的导入数据的模块路径前面拼接上选择的模块路径 if (StringUtils.isNotBlank(request.getModuleId())) { BaseTreeNode baseTreeNode = idModuleMap.get(request.getModuleId()); - String modulePath = baseTreeNode.getPath(); - //如果选择了未规划模块, 导入的数据的模块清空, 只导入数据,不处理模块信息 - if ("root".equals(request.getModuleId())) { - importData.forEach(t -> { - t.setModulePath(modulePath); - }); - } else { - importData.forEach(t -> { - t.setModulePath(modulePath + t.getModulePath()); - }); + if (baseTreeNode != null) { + String modulePath = baseTreeNode.getPath(); + //如果选择了未规划模块, 导入的数据的模块清空, 只导入数据,不处理模块信息 + if ("root".equals(request.getModuleId())) { + importData.forEach(t -> { + t.setModulePath(modulePath); + }); + } else { + importData.forEach(t -> { + t.setModulePath(modulePath + t.getModulePath()); + }); + } } } //去掉apiLists中不存在的模块数据 diff --git a/backend/services/api-test/src/main/java/io/metersphere/api/service/definition/ApiTestCaseService.java b/backend/services/api-test/src/main/java/io/metersphere/api/service/definition/ApiTestCaseService.java index 2092f33e3e..3279d10718 100644 --- a/backend/services/api-test/src/main/java/io/metersphere/api/service/definition/ApiTestCaseService.java +++ b/backend/services/api-test/src/main/java/io/metersphere/api/service/definition/ApiTestCaseService.java @@ -413,6 +413,7 @@ public class ApiTestCaseService extends MoveNodeService { public List doSelectIds(ApiTestCaseBatchRequest request, boolean deleted) { if (request.isSelectAll()) { List ids = extApiTestCaseMapper.getIds(request, deleted); + ids.addAll(request.getSelectIds()); if (CollectionUtils.isNotEmpty(request.getExcludeIds())) { ids.removeAll(request.getExcludeIds()); } diff --git a/backend/services/api-test/src/main/java/io/metersphere/api/service/scenario/ApiScenarioService.java b/backend/services/api-test/src/main/java/io/metersphere/api/service/scenario/ApiScenarioService.java index 1bd961177e..31ee458a5f 100644 --- a/backend/services/api-test/src/main/java/io/metersphere/api/service/scenario/ApiScenarioService.java +++ b/backend/services/api-test/src/main/java/io/metersphere/api/service/scenario/ApiScenarioService.java @@ -2566,19 +2566,38 @@ public class ApiScenarioService extends MoveNodeService { } response.addSuccessData(copyScenario.getId(), copyScenario.getNum(), copyScenario.getName()); } - - response.setSuccess(apiScenarioMapper.batchInsert(insertApiScenarioList)); + SqlSession sqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH); + ApiScenarioMapper mapper = sqlSession.getMapper(ApiScenarioMapper.class); + SubListUtils.dealForSubList(insertApiScenarioList, 100, subList -> { + subList.forEach(mapper::insertSelective); + }); + response.setSuccess(insertApiScenarioList.size()); if (CollectionUtils.isNotEmpty(insertApiScenarioBlobList)) { - apiScenarioBlobMapper.batchInsert(insertApiScenarioBlobList); + ApiScenarioBlobMapper blobMapper = sqlSession.getMapper(ApiScenarioBlobMapper.class); + SubListUtils.dealForSubList(insertApiScenarioBlobList, 100, subList -> { + subList.forEach(blobMapper::insertSelective); + }); } if (CollectionUtils.isNotEmpty(insertApiScenarioStepList)) { - apiScenarioStepMapper.batchInsert(insertApiScenarioStepList); + ApiScenarioStepMapper stepMapper = sqlSession.getMapper(ApiScenarioStepMapper.class); + SubListUtils.dealForSubList(insertApiScenarioStepList, 100, subList -> { + subList.forEach(stepMapper::insertSelective); + }); } if (CollectionUtils.isNotEmpty(insertApiScenarioStepBlobList)) { - apiScenarioStepBlobMapper.batchInsert(insertApiScenarioStepBlobList); + ApiScenarioStepBlobMapper stepBlobMapper = sqlSession.getMapper(ApiScenarioStepBlobMapper.class); + SubListUtils.dealForSubList(insertApiScenarioStepBlobList, 100, subList -> { + subList.forEach(stepBlobMapper::insertSelective); + }); } if (CollectionUtils.isNotEmpty(insertApiFileResourceList)) { - apiFileResourceService.batchInsert(insertApiFileResourceList); + SubListUtils.dealForSubList(insertApiFileResourceList, 100, subList -> { + apiFileResourceService.batchInsert(subList); + }); + } + sqlSession.flushStatements(); + if (sqlSessionFactory != null) { + SqlSessionUtils.closeSqlSession(sqlSession, sqlSessionFactory); } return response; } diff --git a/frontend/src/views/api-test/management/components/import.vue b/frontend/src/views/api-test/management/components/import.vue index 4580fd4767..37b343fd1a 100644 --- a/frontend/src/views/api-test/management/components/import.vue +++ b/frontend/src/views/api-test/management/components/import.vue @@ -415,7 +415,7 @@ () => visible.value, (val) => { if (val) { - importForm.value.moduleId = props.activeModule !== 'all' ? props.activeModule : 'root'; + importForm.value.moduleId = props.activeModule !== 'all' ? props.activeModule : ''; } }, {