From a8910b8370e92225d395d0d0903420b64c902fb6 Mon Sep 17 00:00:00 2001 From: fit2-zhao Date: Thu, 25 Jul 2024 12:09:24 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=B5=8B=E8=AF=95=E8=AE=A1=E5=88=92):=20?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=87=8D=E5=A4=8D=E5=85=B3=E8=81=94=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../plan/service/TestPlanApiCaseService.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanApiCaseService.java b/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanApiCaseService.java index 892e6c864a..12d0df67e3 100644 --- a/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanApiCaseService.java +++ b/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanApiCaseService.java @@ -575,8 +575,17 @@ public class TestPlanApiCaseService extends TestPlanResourceService { //处理数据 handleApiData(collectionAssociates.get(AssociateCaseType.API), user, testPlanApiCaseList, testPlan, isRepeat); handleApiCaseData(collectionAssociates.get(AssociateCaseType.API_CASE), user, testPlanApiCaseList, testPlan, isRepeat); + if (CollectionUtils.isNotEmpty(testPlanApiCaseList)) { - testPlanApiCaseMapper.batchInsert(testPlanApiCaseList); + List distinctList = testPlanApiCaseList.stream() + .collect(Collectors.toMap( + TestPlanApiCase::getApiCaseId, + Function.identity(), + (existing, replacement) -> existing + )) + .values().stream() + .toList(); + testPlanApiCaseMapper.batchInsert(distinctList); } }