From c5c5e76fed3b339972651cb744d1772d58057670 Mon Sep 17 00:00:00 2001 From: MeterSphere Bot <78466014+metersphere-bot@users.noreply.github.com> Date: Tue, 19 Apr 2022 14:15:53 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=8E=A5=E5=8F=A3=E6=B5=8B=E8=AF=95):=20?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=88=A0=E9=99=A4=E5=9C=BA=E6=99=AF=E6=9C=AA?= =?UTF-8?q?=E5=88=A0=E9=99=A4=E5=AE=9A=E6=97=B6=E4=BB=BB=E5=8A=A1=E7=9A=84?= =?UTF-8?q?=E7=BC=BA=E9=99=B7=20(#12781)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1012375 --user=王孝刚 【接口测试】github#12745在接口自动化-场景列表删除已经触发定时任务的场景时,对应的定时触发的场景未被删除 https://www.tapd.cn/55049933/s/1138360 Co-authored-by: wxg0103 <727495428@qq.com> --- .../api/service/ApiAutomationService.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 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 0110c76dee..20440d81f8 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java @@ -517,6 +517,7 @@ public class ApiAutomationService { this.preDelete(s.getId()); testPlanScenarioCaseService.deleteByScenarioId(s.getId()); apiScenarioMapper.deleteByPrimaryKey(s.getId()); + scheduleService.deleteByResourceId(s.getId(), ScheduleGroup.API_SCENARIO_TEST.name()); }); } @@ -599,16 +600,16 @@ public class ApiAutomationService { if (scenario == null) { return; } - ApiScenarioExampleWithOperation example = new ApiScenarioExampleWithOperation(); - example.createCriteria().andRefIdEqualTo(scenario.getRefId()); - example.setOperator(SessionUtils.getUserId()); - example.setOperationTime(System.currentTimeMillis()); - extApiScenarioMapper.removeToGcByExample(example); ApiScenarioRequest request = new ApiScenarioRequest(); request.setRefId(scenario.getRefId()); List scenarioIds = extApiScenarioMapper.selectIdsByQuery(request); //将这些场景的定时任务删除掉 scenarioIds.forEach(scenarioId -> scheduleService.deleteByResourceId(scenarioId, ScheduleGroup.API_SCENARIO_TEST.name())); + ApiScenarioExampleWithOperation example = new ApiScenarioExampleWithOperation(); + example.createCriteria().andRefIdEqualTo(scenario.getRefId()); + example.setOperator(SessionUtils.getUserId()); + example.setOperationTime(System.currentTimeMillis()); + extApiScenarioMapper.removeToGcByExample(example); } } @@ -1897,6 +1898,7 @@ public class ApiAutomationService { ApiScenarioExample example = new ApiScenarioExample(); example.createCriteria().andRefIdEqualTo(refId).andVersionIdEqualTo(version); apiScenarioMapper.deleteByExample(example); + scheduleService.deleteByResourceId(refId, ScheduleGroup.API_SCENARIO_TEST.name()); checkAndSetLatestVersion(refId); }