From 0cb61cc0a79cad97fcfd4acb4d2cb9f8697c6411 Mon Sep 17 00:00:00 2001 From: guoyuqi Date: Mon, 25 Jul 2022 20:00:05 +0800 Subject: [PATCH] =?UTF-8?q?refactor(=E5=B7=A5=E4=BD=9C=E5=8F=B0):=20?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E5=90=8C=E6=AD=A5=E5=8A=9F=E8=83=BD=E6=9B=B4?= =?UTF-8?q?=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --user=郭雨琦 --- .../ApiDefinitionExecResultService.java | 5 ++++- .../api/service/ApiDefinitionService.java | 20 +---------------- .../api/service/ApiTestCaseService.java | 15 +------------ .../metersphere/base/domain/ApiTestCase.java | 3 ++- .../base/mapper/ext/ExtApiTestCaseMapper.xml | 4 ++-- .../project/menu/appmanage/AppManage.vue | 22 +++++++++---------- 6 files changed, 21 insertions(+), 48 deletions(-) diff --git a/backend/src/main/java/io/metersphere/api/service/ApiDefinitionExecResultService.java b/backend/src/main/java/io/metersphere/api/service/ApiDefinitionExecResultService.java index 4f4825d432..ef5e4fab57 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiDefinitionExecResultService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiDefinitionExecResultService.java @@ -273,9 +273,12 @@ public class ApiDefinitionExecResultService { // 更新用例最后执行结果 caseWithBLOBs.setLastResultId(reportId); caseWithBLOBs.setStatus(status); - if (status.equals("success")) { + if (status.equals(APITestStatus.Success.name())) { caseWithBLOBs.setToBeUpdated(false); } + if (status.equals(APITestStatus.Error.name())) { + caseWithBLOBs.setToBeUpdated(true); + } caseWithBLOBs.setUpdateTime(System.currentTimeMillis()); apiTestCaseMapper.updateByPrimaryKey(caseWithBLOBs); 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 a9f903f42d..5293cd02a7 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiDefinitionService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiDefinitionService.java @@ -1013,25 +1013,7 @@ public class ApiDefinitionService { } if (apiDefinition.getToBeUpdated() != null) { - ApiSyncCaseRequest apiSyncCaseRequest = new ApiSyncCaseRequest(); - ApiDefinitionSyncService apiDefinitionSyncService = CommonBeanFactory.getBean(ApiDefinitionSyncService.class); - if (apiDefinitionSyncService != null) { - apiSyncCaseRequest = apiDefinitionSyncService.getApiSyncCaseRequest(apiDefinition.getProjectId()); - } - if (apiSyncCaseRequest.getUnRun() != null && apiSyncCaseRequest.getUnRun() && apiTestCaseWithBLOBs.getStatus() != null && !apiTestCaseWithBLOBs.getStatus().equalsIgnoreCase("Trash") - && !apiTestCaseWithBLOBs.getStatus().equalsIgnoreCase("success") && !apiTestCaseWithBLOBs.getStatus().equalsIgnoreCase("error") - && !apiTestCaseWithBLOBs.getStatus().equalsIgnoreCase("Running") && !apiTestCaseWithBLOBs.getStatus().equalsIgnoreCase("errorReportResult") - && !apiTestCaseWithBLOBs.getStatus().equalsIgnoreCase("STOP")) { - - apiTestCaseWithBLOBs.setToBeUpdated(true); - - } else if (apiSyncCaseRequest.getRunError() != null && apiSyncCaseRequest.getRunError() && apiTestCaseWithBLOBs.getStatus() != null - && !apiTestCaseWithBLOBs.getStatus().equalsIgnoreCase("Trash") - && apiTestCaseWithBLOBs.getStatus().equalsIgnoreCase("error")) { - apiTestCaseWithBLOBs.setToBeUpdated(true); - } else { - apiTestCaseWithBLOBs.setToBeUpdated(false); - } + apiTestCaseWithBLOBs.setToBeUpdated(apiDefinition.getToBeUpdated()); } if (apiDefinition.getToBeUpdateTime() != null) { apiTestCaseWithBLOBs.setToBeUpdateTime(apiDefinition.getToBeUpdateTime()); 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 b0271bc000..ebc11fe7c9 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiTestCaseService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiTestCaseService.java @@ -865,20 +865,7 @@ public class ApiTestCaseService { String requestStr = JSON.toJSONString(req); apiTestCase.setRequest(requestStr); if (toBeUpdated != null) { - if (apiSyncCaseRequest.getUnRun() != null && apiSyncCaseRequest.getUnRun() && apiTestCase.getStatus() != null && !apiTestCase.getStatus().equalsIgnoreCase("Trash") - && !apiTestCase.getStatus().equalsIgnoreCase("success") && !apiTestCase.getStatus().equalsIgnoreCase("error") - && !apiTestCase.getStatus().equalsIgnoreCase("Running") && !apiTestCase.getStatus().equalsIgnoreCase("errorReportResult") - && !apiTestCase.getStatus().equalsIgnoreCase("STOP")) { - - apiTestCase.setToBeUpdated(true); - - } else if (apiSyncCaseRequest.getRunError() != null && apiSyncCaseRequest.getRunError() && apiTestCase.getStatus() != null && !apiTestCase.getStatus().equalsIgnoreCase("Trash") - && apiTestCase.getStatus().equalsIgnoreCase("error")) { - apiTestCase.setToBeUpdated(true); - } else { - apiTestCase.setToBeUpdated(false); - } - + apiTestCase.setToBeUpdated(toBeUpdated); if (toBeUpdated) { apiTestCase.setToBeUpdateTime(System.currentTimeMillis()); } diff --git a/backend/src/main/java/io/metersphere/base/domain/ApiTestCase.java b/backend/src/main/java/io/metersphere/base/domain/ApiTestCase.java index 80357e4cd2..cac8f90330 100644 --- a/backend/src/main/java/io/metersphere/base/domain/ApiTestCase.java +++ b/backend/src/main/java/io/metersphere/base/domain/ApiTestCase.java @@ -1,8 +1,9 @@ package io.metersphere.base.domain; -import java.io.Serializable; import lombok.Data; +import java.io.Serializable; + @Data public class ApiTestCase implements Serializable { private String id; diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiTestCaseMapper.xml b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiTestCaseMapper.xml index 673229e4b6..13acf35ae0 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiTestCaseMapper.xml +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiTestCaseMapper.xml @@ -503,10 +503,10 @@ and (t1.status is null or t1.status != 'Trash') - and t1.to_be_updated = #{request.toBeUpdated} + and ( t1.to_be_updated = #{request.toBeUpdated} or t1.status = 'error') - and (t1.to_be_update_time >= #{request.toBeUpdateTime}) + and (t1.to_be_update_time >= #{request.toBeUpdateTime} or t1.status = 'error') diff --git a/frontend/src/business/components/project/menu/appmanage/AppManage.vue b/frontend/src/business/components/project/menu/appmanage/AppManage.vue index d23f5d7abc..b6457e3d2f 100644 --- a/frontend/src/business/components/project/menu/appmanage/AppManage.vue +++ b/frontend/src/business/components/project/menu/appmanage/AppManage.vue @@ -230,15 +230,15 @@ {{ $t('api_test.request.body') }} - {{ $t('commons.track') + $t('commons.setting') }} - - {{ $t('project.code_segment.result') + ":" }} - - {{ $t('schedule.event_failed') }} - {{ $t('api_test.home_page.detail_card.unexecute') }} - - - + 取 消 @@ -410,8 +410,8 @@ export default { query: true, rest: true, body: true, - runError: true, - unRun: true + runError: false, + unRun: false } } this.apiSyncCaseRequest.protocol = true;