fix(测试计划): 修复重复关联问题

This commit is contained in:
fit2-zhao 2024-07-25 12:09:24 +08:00 committed by Craftsman
parent 3652b3db10
commit a8910b8370
1 changed files with 10 additions and 1 deletions

View File

@ -575,8 +575,17 @@ public class TestPlanApiCaseService extends TestPlanResourceService {
//处理数据 //处理数据
handleApiData(collectionAssociates.get(AssociateCaseType.API), user, testPlanApiCaseList, testPlan, isRepeat); handleApiData(collectionAssociates.get(AssociateCaseType.API), user, testPlanApiCaseList, testPlan, isRepeat);
handleApiCaseData(collectionAssociates.get(AssociateCaseType.API_CASE), user, testPlanApiCaseList, testPlan, isRepeat); handleApiCaseData(collectionAssociates.get(AssociateCaseType.API_CASE), user, testPlanApiCaseList, testPlan, isRepeat);
if (CollectionUtils.isNotEmpty(testPlanApiCaseList)) { if (CollectionUtils.isNotEmpty(testPlanApiCaseList)) {
testPlanApiCaseMapper.batchInsert(testPlanApiCaseList); List<TestPlanApiCase> distinctList = testPlanApiCaseList.stream()
.collect(Collectors.toMap(
TestPlanApiCase::getApiCaseId,
Function.identity(),
(existing, replacement) -> existing
))
.values().stream()
.toList();
testPlanApiCaseMapper.batchInsert(distinctList);
} }
} }