fix(接口测试): 修复删除场景未删除定时任务的缺陷

--bug=1012375 --user=王孝刚
【接口测试】github#12745在接口自动化-场景列表删除已经触发定时任务的场景时,对应的定时触发的场景未被删除
https://www.tapd.cn/55049933/s/1138360
This commit is contained in:
wxg0103 2022-04-18 17:20:30 +08:00 committed by 刘瑞斌
parent b0e7151f7d
commit c9f9fdbca3
1 changed files with 7 additions and 5 deletions

View File

@ -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<String> 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);
}