From bac7bbf85abf473a28313a7fe6b38c9cc1dc8167 Mon Sep 17 00:00:00 2001 From: junhong Date: Mon, 24 Jan 2022 20:26:27 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=B5=8B=E8=AF=95=E8=B7=9F=E8=B8=AA):=20?= =?UTF-8?q?=E5=90=AF=E7=94=A8=E8=87=AA=E5=AE=9A=E4=B9=89=20ID=20=E6=97=B6?= =?UTF-8?q?=E8=84=91=E5=9B=BE=E5=8F=AF=E9=87=8D=E5=A4=8D=E5=AF=BC=E5=85=A5?= =?UTF-8?q?=E7=9B=B8=E5=90=8C=20ID=20=E7=9A=84=20bug=20=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1008968 --user=周骏弘 【功能用例】项目启用测试用例自定义id时,采用脑图导入可重复导入,id重复了。 https://www.tapd.cn/55049933/s/1097728 --- .../io/metersphere/xmind/XmindCaseParser.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/backend/src/main/java/io/metersphere/xmind/XmindCaseParser.java b/backend/src/main/java/io/metersphere/xmind/XmindCaseParser.java index 2637209b17..960b2ba14e 100644 --- a/backend/src/main/java/io/metersphere/xmind/XmindCaseParser.java +++ b/backend/src/main/java/io/metersphere/xmind/XmindCaseParser.java @@ -254,6 +254,19 @@ public class XmindCaseParser { } } + // 判断新增 + if (StringUtils.equals(importType, FunctionCaseImportEnum.Create.name())) { + String checkResult; + // 针对自定义 ID 的情况做重复判断 + if (isUseCustomId) { + checkResult = testCaseService.checkCustomIdExist(data.getCustomNum(), projectId); + if (null != checkResult) { //该ID在当前项目中存在 + process.add(Translator.get("custom_num_is_exist"), nodePath + "/" + compartData.getName()); + return false; + } + } + } + if (validatePass) { this.continueValidatedCase.add(data); } @@ -267,6 +280,7 @@ public class XmindCaseParser { for (Attached item : attacheds) { if (isAvailable(item.getTitle(), TC_REGEX)) { item.setParent(parent); + // 格式化一个用例 this.formatTestCase(item.getTitle(), parent.getPath(), item.getChildren() != null ? item.getChildren().getAttached() : null); } else { String nodePath = parent.getPath().trim() + "/" + item.getTitle().trim(); @@ -430,6 +444,7 @@ public class XmindCaseParser { String nodePath = item.getTitle(); item.setPath(nodePath); if (item.getChildren() != null && !item.getChildren().getAttached().isEmpty()) { + // 递归处理案例数据 recursion(item, 1, item.getChildren().getAttached()); } else { if (!nodePath.startsWith("/")) {