fix(接口测试): 优化删除场景时场景定时任务配置的处理方式

--bug=1025682 --user=宋天阳 【接口测试】场景开启定时任务-删除场景再恢复场景-定时任务显示未设置
https://www.tapd.cn/55049933/s/1365246
This commit is contained in:
song-tianyang 2023-04-21 15:26:39 +08:00 committed by 刘瑞斌
parent 082cf6fc9e
commit 8f4572d99c
3 changed files with 15 additions and 2 deletions

View File

@ -89,6 +89,18 @@ public class ExtApiScheduleService {
return scheduleMapper.deleteByExample(scheduleExample);
}
public void closeByResourceId(String resourceId, String group) {
ScheduleExample scheduleExample = new ScheduleExample();
scheduleExample.createCriteria().andResourceIdEqualTo(resourceId);
removeJob(resourceId, group);
List<Schedule> list = scheduleMapper.selectByExample(scheduleExample);
for (Schedule schedule : list) {
schedule.setEnable(false);
scheduleMapper.updateByPrimaryKey(schedule);
}
}
public int deleteByProjectId(String projectId) {
ScheduleExample scheduleExample = new ScheduleExample();
scheduleExample.createCriteria().andProjectIdEqualTo(projectId);

View File

@ -617,7 +617,7 @@ public class ApiScenarioService {
return;
}
List<String> scenarioIds = apiScenarioVersions.stream().map(ApiScenario::getId).collect(toList());
scenarioIds.forEach(scenarioId -> scheduleService.deleteByResourceId(scenarioId, ScheduleGroup.API_SCENARIO_TEST.name()));
scenarioIds.forEach(scenarioId -> scheduleService.closeByResourceId(scenarioId, ScheduleGroup.API_SCENARIO_TEST.name()));
ApiScenarioExampleWithOperation example = new ApiScenarioExampleWithOperation();
example.createCriteria().andRefIdIn(refIds);
@ -736,7 +736,7 @@ public class ApiScenarioService {
ApiScenarioEnvRequest request = new ApiScenarioEnvRequest();
request.setEnvironmentEnable(false);
request.setDefinition(scenarioWithBLOBs.getScenarioDefinition());
request.setEnvironmentMap( JSON.parseObject(scenarioWithBLOBs.getEnvironmentJson(), Map.class));
request.setEnvironmentMap(JSON.parseObject(scenarioWithBLOBs.getEnvironmentJson(), Map.class));
request.setEnvironmentType(scenarioWithBLOBs.getEnvironmentType());
request.setEnvironmentGroupId(scenarioWithBLOBs.getEnvironmentGroupId());
request.setId(scenarioWithBLOBs.getId());

View File

@ -198,6 +198,7 @@
:field="item"
:fields-width="fieldsWidth"
min-width="100px"
v-if="!trashEnable"
:filters="!trashEnable ? scheduleFilters : null"
prop="schedule">
<template v-slot:default="scope">