refactor(接口测试): 删除任务重跑无用代码
Some checks failed
MeterSphere 自动创建 PR / 自动创建 PR (push) Has been cancelled

This commit is contained in:
AgAngle 2024-11-27 11:15:42 +08:00
parent aa046e18d2
commit 28ad9ac5f9

View File

@ -1,15 +1,10 @@
package io.metersphere.system.service;
import io.metersphere.api.domain.ApiReportRelateTaskExample;
import io.metersphere.api.mapper.ApiReportRelateTaskMapper;
import io.metersphere.sdk.constants.ExecStatus;
import io.metersphere.sdk.constants.ExecTaskType;
import io.metersphere.system.domain.ExecTask;
import io.metersphere.system.mapper.ExecTaskMapper;
import io.metersphere.system.mapper.ExtExecTaskItemMapper;
import jakarta.annotation.Resource;
import org.apache.commons.lang3.BooleanUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
@ -26,8 +21,6 @@ public class ExecTaskService {
private ExecTaskMapper execTaskMapper;
@Resource
private ExtExecTaskItemMapper extExecTaskItemMapper;
@Resource
private ApiReportRelateTaskMapper apiReportRelateTaskMapper;
@Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRES_NEW)
public void updateTaskRerunStatus(ExecTask execTask, String userId) {
@ -38,13 +31,6 @@ public class ExecTaskService {
execTask.setResult(ExecStatus.PENDING.name());
execTaskMapper.updateByPrimaryKey(execTask);
if (BooleanUtils.isFalse(execTask.getIntegrated()) && !StringUtils.equalsAny(execTask.getTaskType(), ExecTaskType.TEST_PLAN.name(), ExecTaskType.TEST_PLAN_GROUP.name())) {
// 非集合报告和测试计划执行则删除任务和报告的关联关系
ApiReportRelateTaskExample example = new ApiReportRelateTaskExample();
example.createCriteria().andTaskResourceIdEqualTo(execTask.getId());
apiReportRelateTaskMapper.deleteByExample(example);
}
// 新建需要重跑的任务项
extExecTaskItemMapper.insertRerunTaskItem(execTask.getId(), userId);
// 假删除原有任务项执行历史需要能查询到