diff --git a/backend/src/main/java/io/metersphere/api/service/ApiTestCaseService.java b/backend/src/main/java/io/metersphere/api/service/ApiTestCaseService.java index 769ee8cfde..88ebd7ccb5 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiTestCaseService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiTestCaseService.java @@ -620,16 +620,12 @@ public class ApiTestCaseService { return ids; } - private ApiDefinitionExecResult addResult(String id, String status, ApiDefinitionExecResultMapper batchMapper) { + private ApiDefinitionExecResult addResult(String id, String status) { ApiDefinitionExecResult apiResult = new ApiDefinitionExecResult(); apiResult.setId(UUID.randomUUID().toString()); apiResult.setCreateTime(System.currentTimeMillis()); apiResult.setStartTime(System.currentTimeMillis()); apiResult.setEndTime(System.currentTimeMillis()); - ApiTestCaseWithBLOBs caseWithBLOBs = apiTestCaseMapper.selectByPrimaryKey(id); - if (caseWithBLOBs != null) { - apiResult.setName(caseWithBLOBs.getName()); - } apiResult.setTriggerMode(TriggerMode.BATCH.name()); apiResult.setActuator("LOCAL"); apiResult.setUserId(Objects.requireNonNull(SessionUtils.getUser()).getId()); @@ -637,11 +633,6 @@ public class ApiTestCaseService { apiResult.setStartTime(System.currentTimeMillis()); apiResult.setType(ApiRunMode.DEFINITION.name()); apiResult.setStatus(status); - batchMapper.insert(apiResult); - caseWithBLOBs.setLastResultId(apiResult.getId()); - caseWithBLOBs.setUpdateTime(System.currentTimeMillis()); - caseWithBLOBs.setStatus(APITestStatus.Running.name()); - apiTestCaseMapper.updateByPrimaryKey(caseWithBLOBs); return apiResult; } @@ -651,10 +642,20 @@ public class ApiTestCaseService { Map executeQueue = new HashMap<>(); SqlSession sqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH); ApiDefinitionExecResultMapper batchMapper = sqlSession.getMapper(ApiDefinitionExecResultMapper.class); - request.getIds().forEach(testCaseId -> { - ApiDefinitionExecResult report = addResult(testCaseId, APITestStatus.Running.name(), batchMapper); + + for (String testCaseId : request.getIds()) { + ApiDefinitionExecResult report = addResult(testCaseId, APITestStatus.Running.name()); + ApiTestCaseWithBLOBs caseWithBLOBs = apiTestCaseMapper.selectByPrimaryKey(testCaseId); + if (caseWithBLOBs != null) { + report.setName(caseWithBLOBs.getName()); + caseWithBLOBs.setLastResultId(report.getId()); + caseWithBLOBs.setUpdateTime(System.currentTimeMillis()); + caseWithBLOBs.setStatus(APITestStatus.Running.name()); + apiTestCaseMapper.updateByPrimaryKey(caseWithBLOBs); + } + batchMapper.insert(report); executeQueue.put(testCaseId, report); - }); + } sqlSession.flushStatements(); for (String caseId : executeQueue.keySet()) { RunCaseRequest runCaseRequest = new RunCaseRequest(); diff --git a/backend/src/main/java/io/metersphere/log/vo/api/DefinitionReference.java b/backend/src/main/java/io/metersphere/log/vo/api/DefinitionReference.java index 70e68a90ef..996e064a32 100644 --- a/backend/src/main/java/io/metersphere/log/vo/api/DefinitionReference.java +++ b/backend/src/main/java/io/metersphere/log/vo/api/DefinitionReference.java @@ -22,6 +22,7 @@ public class DefinitionReference { definitionColumns.put("request", "请求参数"); definitionColumns.put("response", "返回参数"); definitionColumns.put("description", "描述"); + definitionColumns.put("followPeople", "关注人"); // 需要深度对比的字段,可以支持多个req1,req2 definitionColumns.put("ms-dff-col", "request,response,tags"); @@ -33,6 +34,8 @@ public class DefinitionReference { caseColumns.put("tags", "标签"); caseColumns.put("description", "描述"); caseColumns.put("request", "请求参数"); + caseColumns.put("followPeople", "关注人"); + // 深度对比字段 caseColumns.put("ms-dff-col", "request,tags"); diff --git a/frontend/src/business/components/api/definition/components/import/ApiImport.vue b/frontend/src/business/components/api/definition/components/import/ApiImport.vue index 5c17c8512b..268192361d 100644 --- a/frontend/src/business/components/api/definition/components/import/ApiImport.vue +++ b/frontend/src/business/components/api/definition/components/import/ApiImport.vue @@ -339,7 +339,8 @@ close() { this.formData = { file: undefined, - swaggerUrl: '' + swaggerUrl: '', + modeId: this.formData.modeId, }; this.fileList = []; removeGoBackListener(this.close);