feat(测试计划): 取消项目关联时取消性能测试用例关联

This commit is contained in:
shiziyuan9527 2021-01-08 11:36:41 +08:00
parent 963156a969
commit a8a9664070
3 changed files with 21 additions and 0 deletions

View File

@ -1,6 +1,7 @@
package io.metersphere.track.service;
import io.metersphere.base.domain.*;
import io.metersphere.base.mapper.LoadTestMapper;
import io.metersphere.base.mapper.LoadTestReportMapper;
import io.metersphere.base.mapper.TestPlanLoadCaseMapper;
import io.metersphere.base.mapper.ext.ExtTestPlanLoadCaseMapper;
@ -20,6 +21,7 @@ import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import java.util.stream.Collectors;
@Service
@Transactional(rollbackFor = Exception.class)
@ -35,6 +37,8 @@ public class TestPlanLoadCaseService {
private SqlSessionFactory sqlSessionFactory;
@Resource
private LoadTestReportMapper loadTestReportMapper;
@Resource
private LoadTestMapper loadTestMapper;
public List<LoadTest> relevanceList(LoadCaseRequest request) {
List<String> ids = extTestPlanLoadCaseMapper.selectIdsNotInPlan(request.getProjectId(), request.getTestPlanId());
@ -96,4 +100,17 @@ public class TestPlanLoadCaseService {
}
return true;
}
public void deleteByRelevanceProjectIds(String id, List<String> relevanceProjectIds) {
LoadTestExample loadTestExample = new LoadTestExample();
loadTestExample.createCriteria().andProjectIdIn(relevanceProjectIds);
List<LoadTest> loadTests = loadTestMapper.selectByExample(loadTestExample);
TestPlanLoadCaseExample testPlanLoadCaseExample = new TestPlanLoadCaseExample();
TestPlanLoadCaseExample.Criteria criteria = testPlanLoadCaseExample.createCriteria().andTestPlanIdEqualTo(id);
if (!CollectionUtils.isEmpty(loadTests)) {
List<String> ids = loadTests.stream().map(LoadTest::getId).collect(Collectors.toList());
criteria.andLoadCaseIdNotIn(ids);
}
testPlanLoadCaseMapper.deleteByExample(testPlanLoadCaseExample);
}
}

View File

@ -87,6 +87,8 @@ public class TestPlanService {
private TestPlanApiCaseService testPlanApiCaseService;
@Resource
private TestPlanScenarioCaseService testPlanScenarioCaseService;
@Resource
private TestPlanLoadCaseService testPlanLoadCaseService;
public synchronized void addTestPlan(AddTestPlanRequest testPlan) {
if (getTestPlanByName(testPlan.getName()).size() > 0) {
@ -234,6 +236,7 @@ public class TestPlanService {
}
testPlanApiCaseService.deleteByRelevanceProjectIds(testPlan.getId(), relevanceProjectIds);
testPlanScenarioCaseService.deleteByRelevanceProjectIds(testPlan.getId(), relevanceProjectIds);
testPlanLoadCaseService.deleteByRelevanceProjectIds(testPlan.getId(), relevanceProjectIds);
}
}

View File

@ -167,6 +167,7 @@ export default {
},
methods: {
initTable() {
this.selectRows = new Set();
let param = {};
param.testPlanId = this.planId;
if (this.selectProjectId && this.selectProjectId !== 'root') {