From 0426917cd673a37c0435681f251569170989d29a Mon Sep 17 00:00:00 2001 From: caofengbin <1050430934@qq.com> Date: Tue, 28 May 2024 17:26:17 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=9D=E5=AD=98=E5=85=AC=E5=85=B1=E6=AD=A5?= =?UTF-8?q?=E9=AA=A4=E6=97=B6=EF=BC=8C=E5=88=A4=E6=96=AD=E4=B8=8B=E6=98=AF?= =?UTF-8?q?=E5=90=A6=E6=9C=89=E5=AD=90=E6=AD=A5=E9=AA=A4=E5=BC=95=E7=94=A8?= =?UTF-8?q?=E4=BA=86=E5=BD=93=E5=89=8D=E7=88=B6=E6=AD=A5=E9=AA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/PublicStepsController.java | 3 +++ .../controller/services/PublicStepsService.java | 8 ++++++++ .../services/impl/PublicStepsServiceImpl.java | 17 +++++++++++++++++ 3 files changed, 28 insertions(+) diff --git a/sonic-server-controller/src/main/java/org/cloud/sonic/controller/controller/PublicStepsController.java b/sonic-server-controller/src/main/java/org/cloud/sonic/controller/controller/PublicStepsController.java index 017613d6..c13b8d2a 100644 --- a/sonic-server-controller/src/main/java/org/cloud/sonic/controller/controller/PublicStepsController.java +++ b/sonic-server-controller/src/main/java/org/cloud/sonic/controller/controller/PublicStepsController.java @@ -82,6 +82,9 @@ public RespModel>> findByProjectId(@RequestParam(name = @Operation(summary = "更新公共步骤信息", description = "新增或更新公共步骤信息") @PutMapping public RespModel save(@Validated @RequestBody PublicStepsDTO publicStepsDTO) { + if (publicStepsService.checkPublicStepRecursion(publicStepsDTO)) { + return new RespModel<>(RespEnum.UPDATE_FAIL, "子步骤中存在对当前公共步骤的引用,请移除掉相关步骤"); + } return new RespModel(RespEnum.UPDATE_OK, publicStepsService.savePublicSteps(publicStepsDTO)); } diff --git a/sonic-server-controller/src/main/java/org/cloud/sonic/controller/services/PublicStepsService.java b/sonic-server-controller/src/main/java/org/cloud/sonic/controller/services/PublicStepsService.java index 0d634d12..ff5306da 100644 --- a/sonic-server-controller/src/main/java/org/cloud/sonic/controller/services/PublicStepsService.java +++ b/sonic-server-controller/src/main/java/org/cloud/sonic/controller/services/PublicStepsService.java @@ -31,4 +31,12 @@ public interface PublicStepsService extends IService { * 复制公共用例 */ void copyPublicSetpsIds(int id); + + /** + * 判断公共步骤的子步骤是否存在递归调用的场景 + * + * @param publicStepsDTO 公共步骤bean + * @return true表示出现了递归调用 + */ + boolean checkPublicStepRecursion(PublicStepsDTO publicStepsDTO); } diff --git a/sonic-server-controller/src/main/java/org/cloud/sonic/controller/services/impl/PublicStepsServiceImpl.java b/sonic-server-controller/src/main/java/org/cloud/sonic/controller/services/impl/PublicStepsServiceImpl.java index b53633b9..d65d935e 100644 --- a/sonic-server-controller/src/main/java/org/cloud/sonic/controller/services/impl/PublicStepsServiceImpl.java +++ b/sonic-server-controller/src/main/java/org/cloud/sonic/controller/services/impl/PublicStepsServiceImpl.java @@ -246,4 +246,21 @@ public void copyPublicSetpsIds(int id) { } } + @Override + public boolean checkPublicStepRecursion(PublicStepsDTO publicStepsDTO) { + if (publicStepsDTO.getId() == null) { + return false; + } + if (publicStepsDTO.getSteps() != null && publicStepsDTO.getSteps().size() > 0) { + for (StepsDTO curStepsDTO : publicStepsDTO.getSteps()) { + if (curStepsDTO.getStepType().equals("publicStep")) { + String curText = curStepsDTO.getText(); + if (publicStepsDTO.getId().toString().equals(curText)) { + return true; + } + } + } + } + return false; + } } \ No newline at end of file