fix(接口测试): 接口测试批量开启关闭定时任务时没有涉及到的场景不记录日志

This commit is contained in:
Jianguo-Genius 2024-11-27 11:21:46 +08:00 committed by Craftsman
parent 35f2d1a572
commit 172c7e35c1
2 changed files with 15 additions and 6 deletions

View File

@ -2556,7 +2556,12 @@ public class ApiScenarioService extends MoveNodeService {
if (CollectionUtils.isNotEmpty(apiScenarios)) {
if (StringUtils.isBlank(request.getCron()) && request.getConfig() == null) {
this.batchUpdateSchedule(apiScenarios, request.isEnable(), operator);
List<String> operationIds = this.batchUpdateSchedule(apiScenarios, request.isEnable(), operator);
example.clear();
example.createCriteria().andIdIn(operationIds).andDeletedEqualTo(false);
apiScenarios = apiScenarioMapper.selectByExample(example);
} else {
if (StringUtils.isBlank(request.getCron())) {
throw new MSException("Cron can not be null");
@ -2586,12 +2591,16 @@ public class ApiScenarioService extends MoveNodeService {
}
}
private void batchUpdateSchedule(List<ApiScenario> apiScenarioList, boolean isScheudleOpen, String userId) {
private List<String> batchUpdateSchedule(List<ApiScenario> apiScenarioList, boolean isScheudleOpen, String userId) {
//批量编辑定时任务
List<String> scenarioIds = new ArrayList<>();
for (ApiScenario apiScenario : apiScenarioList) {
scheduleService.updateIfExist(apiScenario.getId(), isScheudleOpen, ApiScenarioScheduleJob.getJobKey(apiScenario.getId()),
ApiScenarioScheduleJob.getTriggerKey(apiScenario.getId()), ApiScenarioScheduleJob.class, userId);
scenarioIds.addAll(
scheduleService.updateIfExist(apiScenario.getId(), isScheudleOpen, ApiScenarioScheduleJob.getJobKey(apiScenario.getId()),
ApiScenarioScheduleJob.getTriggerKey(apiScenario.getId()), ApiScenarioScheduleJob.class, userId)
);
}
return scenarioIds;
}
// 场景统计相关

View File

@ -19,7 +19,6 @@ import org.quartz.TriggerKey;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
import java.util.UUID;
@Transactional(rollbackFor = Exception.class)
public class ScheduleService {
@ -121,7 +120,7 @@ public class ScheduleService {
}
}
public void updateIfExist(String resourceId, boolean enable, JobKey jobKey, TriggerKey triggerKey, Class clazz, String operator) {
public List<String> updateIfExist(String resourceId, boolean enable, JobKey jobKey, TriggerKey triggerKey, Class clazz, String operator) {
ScheduleExample example = new ScheduleExample();
example.createCriteria().andResourceIdEqualTo(resourceId).andJobEqualTo(clazz.getName());
List<Schedule> scheduleList = scheduleMapper.selectByExample(example);
@ -140,6 +139,7 @@ public class ScheduleService {
}
}
}
return scheduleList.stream().map(Schedule::getResourceId).toList();
}
public String scheduleConfig(ScheduleConfig scheduleConfig, JobKey jobKey, TriggerKey triggerKey, Class clazz, String operator) {