feat: 删除用例时删除关联的缺陷
This commit is contained in:
parent
1038f50c3f
commit
0602044d6a
|
@ -0,0 +1,36 @@
|
|||
package io.metersphere.track.service;
|
||||
|
||||
import io.metersphere.base.domain.TestCaseIssues;
|
||||
import io.metersphere.base.domain.TestCaseIssuesExample;
|
||||
import io.metersphere.base.mapper.IssuesMapper;
|
||||
import io.metersphere.base.mapper.TestCaseIssuesMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public class TestCaseIssueService {
|
||||
|
||||
@Resource
|
||||
private TestCaseIssuesMapper testCaseIssuesMapper;
|
||||
@Resource
|
||||
private IssuesMapper issuesMapper;
|
||||
|
||||
public void delTestCaseIssues(String testCaseId) {
|
||||
TestCaseIssuesExample example = new TestCaseIssuesExample();
|
||||
example.createCriteria().andTestCaseIdEqualTo(testCaseId);
|
||||
List<TestCaseIssues> testCaseIssues = testCaseIssuesMapper.selectByExample(example);
|
||||
if (!CollectionUtils.isEmpty(testCaseIssues)) {
|
||||
List<String> list = testCaseIssues.stream().map(TestCaseIssues::getIssuesId).collect(Collectors.toList());
|
||||
list.forEach(id -> {
|
||||
issuesMapper.deleteByPrimaryKey(id);
|
||||
});
|
||||
}
|
||||
testCaseIssuesMapper.deleteByExample(example);
|
||||
}
|
||||
}
|
|
@ -73,6 +73,9 @@ public class TestCaseService {
|
|||
@Resource
|
||||
UserRoleMapper userRoleMapper;
|
||||
|
||||
@Resource
|
||||
TestCaseIssueService testCaseIssueService;
|
||||
|
||||
public void addTestCase(TestCaseWithBLOBs testCase) {
|
||||
testCase.setName(testCase.getName());
|
||||
checkTestCaseExist(testCase);
|
||||
|
@ -149,6 +152,7 @@ public class TestCaseService {
|
|||
TestPlanTestCaseExample example = new TestPlanTestCaseExample();
|
||||
example.createCriteria().andCaseIdEqualTo(testCaseId);
|
||||
testPlanTestCaseMapper.deleteByExample(example);
|
||||
testCaseIssueService.delTestCaseIssues(testCaseId);
|
||||
return testCaseMapper.deleteByPrimaryKey(testCaseId);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue