Skip to content

Commit

Permalink
优化删除项目时,清理测试套件相关记录的逻辑,改成返回每个子循环的bool
Browse files Browse the repository at this point in the history
  • Loading branch information
caofengbin committed May 13, 2023
1 parent 1fb0457 commit cda3f6f
Showing 1 changed file with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -443,8 +443,15 @@ public List<TestSuitesDTO> findByProjectId(int projectId) {
public boolean deleteByProjectId(int projectId) {
List<TestSuites> testSuitesList = baseMapper.selectList(
new LambdaQueryWrapper<TestSuites>().eq(TestSuites::getProjectId, projectId));
testSuitesList.forEach(curTestSuites -> delete(curTestSuites.getId()));
return testSuitesList.size() > 0;
if (testSuitesList != null && !testSuitesList.isEmpty()) {
return testSuitesList.stream()
.map(TestSuites::getId)
.map(this::delete)
.reduce(true, Boolean::logicalAnd);
} else {
// 如果查询到的list不会null,但是数量为0,说明本身不存在测试套件,直接返回true。
return testSuitesList != null;
}
}

@Override
Expand Down

0 comments on commit cda3f6f

Please sign in to comment.