Skip to content

Commit

Permalink
Merge pull request #447 from caofengbin/feature/check_public_step_rec…
Browse files Browse the repository at this point in the history
…ursion

【feat】保存公共步骤时,判断下是否有子步骤引用了当前父步骤
  • Loading branch information
ZhouYixun authored Jun 4, 2024
2 parents 762f187 + 0426917 commit c303b90
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ public RespModel<List<Map<String, Object>>> findByProjectId(@RequestParam(name =
@Operation(summary = "更新公共步骤信息", description = "新增或更新公共步骤信息")
@PutMapping
public RespModel<String> save(@Validated @RequestBody PublicStepsDTO publicStepsDTO) {
if (publicStepsService.checkPublicStepRecursion(publicStepsDTO)) {
return new RespModel<>(RespEnum.UPDATE_FAIL, "子步骤中存在对当前公共步骤的引用,请移除掉相关步骤");
}
return new RespModel(RespEnum.UPDATE_OK, publicStepsService.savePublicSteps(publicStepsDTO));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,12 @@ public interface PublicStepsService extends IService<PublicSteps> {
* 复制公共用例
*/
void copyPublicSetpsIds(int id);

/**
* 判断公共步骤的子步骤是否存在递归调用的场景
*
* @param publicStepsDTO 公共步骤bean
* @return true表示出现了递归调用
*/
boolean checkPublicStepRecursion(PublicStepsDTO publicStepsDTO);
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

0 comments on commit c303b90

Please sign in to comment.