解决循环或轮询编排bug

This commit is contained in:
liangdaliang
2025-03-12 18:22:24 +08:00
parent 2cdc43cd0f
commit 96e1237c20
6 changed files with 88 additions and 12 deletions

View File

@@ -68,5 +68,13 @@ public interface TestCaseStepMapper
*/
public List<TestCaseStep> selectTestCaseStepListByCaseId(Long caseId);
/**
* 根据用例id查询所有用例步骤列表并按照步骤顺序排序
*
* @param caseId 用例id
* @return 用例步骤集合
*/
public List<Long> selectAllTestCaseStepIdListByCaseId(Long caseId);
int deleteTestCaseStepByCaseId(Long caseId);
}

View File

@@ -76,10 +76,20 @@ public class TestCaseStepServiceImpl implements ITestCaseStepService {
@Override
@Transactional
public int insertBatchTestCaseStep(TestCaseStepAddQO qo) {
testCaseStepMapper.deleteTestCaseStepByCaseId(qo.getCaseId());
List<Long> allTestCaseStepIdList =
testCaseStepMapper.selectAllTestCaseStepIdListByCaseId(qo.getCaseId());
int i = 0;
for (TestCaseStep testCaseStep1 : qo.getList()) {
i += insertTestCaseStep(testCaseStep1);
if (testCaseStep1.getId() != null) {
allTestCaseStepIdList.remove(testCaseStep1.getId());
updateTestCaseStep(testCaseStep1);
} else {
insertTestCaseStep(testCaseStep1);
}
i ++;
}
for (Long testCaseStepId : allTestCaseStepIdList) {
deleteTestCaseStepById(testCaseStepId);
}
return i;
}

View File

@@ -235,4 +235,9 @@
where case_id = #{caseId} and del_flag = '0' and parent_id is null
ORDER BY step_num
</select>
<select id="selectAllTestCaseStepIdListByCaseId" parameterType="Long" resultType="Long">
select id from test_case_step
where case_id = #{caseId} and del_flag = '0'
</select>
</mapper>