From 5a25fc51236441e3e6dfb333df7c0bf448d7bcf0 Mon Sep 17 00:00:00 2001 From: guoyuqi Date: Fri, 11 Mar 2022 16:55:26 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=8E=A5=E5=8F=A3=E6=B5=8B=E8=AF=95):=20?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E8=87=AA=E5=8A=A8=E5=8C=96=E7=BC=96=E8=BE=91?= =?UTF-8?q?=E5=AF=BC=E5=85=A5=E5=AF=BC=E5=87=BA=E4=B8=8D=E6=A3=80=E6=9F=A5?= =?UTF-8?q?=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --user=郭雨琦 接口自动化编辑导入导出不检查数据 --- .../api/service/ApiAutomationService.java | 24 +++---------------- 1 file changed, 3 insertions(+), 21 deletions(-) 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 14ad098d55..f672114de4 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java @@ -238,14 +238,7 @@ public class ApiAutomationService { request.setCustomNum(String.valueOf(nextNum)); } checkScenarioNum(request); - SqlSession sqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH); - ApiTestCaseMapper apiTestCaseMapper = sqlSession.getMapper(ApiTestCaseMapper.class); - ApiDefinitionMapper apiDefinitionMapper = sqlSession.getMapper(ApiDefinitionMapper.class); - final ApiScenarioWithBLOBs scenario = buildSaveScenario(request,apiTestCaseMapper,apiDefinitionMapper); - sqlSession.flushStatements(); - if (sqlSession != null && sqlSessionFactory != null) { - SqlSessionUtils.closeSqlSession(sqlSession, sqlSessionFactory); - } + final ApiScenarioWithBLOBs scenario = buildSaveScenario(request); scenario.setVersion(0); scenario.setCreateTime(System.currentTimeMillis()); @@ -351,17 +344,7 @@ public class ApiAutomationService { esbApiParamService.checkScenarioRequests(request); //如果场景有TCP步骤的话,也要做参数计算处理 tcpApiParamService.checkTestElement(request.getScenarioDefinition()); - - //检查是否要增加引用的步骤的CASE类型的数据 - SqlSession sqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH); - ApiTestCaseMapper apiTestCaseMapper = sqlSession.getMapper(ApiTestCaseMapper.class); - ApiDefinitionMapper apiDefinitionMapper = sqlSession.getMapper(ApiDefinitionMapper.class); - final ApiScenarioWithBLOBs scenario = buildSaveScenario(request,apiTestCaseMapper,apiDefinitionMapper); - - sqlSession.flushStatements(); - if (sqlSession != null && sqlSessionFactory != null) { - SqlSessionUtils.closeSqlSession(sqlSession, sqlSessionFactory); - } + final ApiScenarioWithBLOBs scenario = buildSaveScenario(request); ApiScenarioWithBLOBs beforeScenario = apiScenarioMapper.selectByPrimaryKey(request.getId()); Integer version = beforeScenario.getVersion(); @@ -454,7 +437,7 @@ public class ApiAutomationService { .map(MsHTTPSamplerProxy::getId).collect(Collectors.toSet()); } - public ApiScenarioWithBLOBs buildSaveScenario(SaveApiScenarioRequest request,ApiTestCaseMapper apiTestCaseMapper,ApiDefinitionMapper apiDefinitionMapper) { + public ApiScenarioWithBLOBs buildSaveScenario(SaveApiScenarioRequest request) { ApiScenarioWithBLOBs scenario = new ApiScenarioWithBLOBs(); scenario.setId(request.getId()); scenario.setName(request.getName()); @@ -503,7 +486,6 @@ public class ApiAutomationService { } else { scenario.setVersionId(request.getVersionId()); } - checkReferenceCase(scenario,apiTestCaseMapper,apiDefinitionMapper); return scenario; }