Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

【feat】保存公共步骤时,判断下是否有子步骤引用了当前父步骤 #447

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
}
}
Loading