From c5a541e829d75ad07e6083fd9493f76e18c60f20 Mon Sep 17 00:00:00 2001 From: caofengbin <1050430934@qq.com> Date: Mon, 4 Sep 2023 11:28:28 +0800 Subject: [PATCH] =?UTF-8?q?=E5=90=8E=E7=AB=AF=E6=8E=A5=E5=8F=A3=E5=AE=9E?= =?UTF-8?q?=E7=8E=B0=E5=9C=A8=E5=BD=93=E5=89=8D=E8=A1=8C=E7=9A=84=E4=B8=8B?= =?UTF-8?q?=E6=96=B9=E5=A4=8D=E5=88=B6=E6=AD=A5=E9=AA=A4=E7=9A=84=E8=83=BD?= =?UTF-8?q?=E5=8A=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/controller/StepsController.java | 8 +++++--- .../sonic/controller/services/StepsService.java | 2 +- .../controller/services/impl/StepsServiceImpl.java | 14 +++++++++++++- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/sonic-server-controller/src/main/java/org/cloud/sonic/controller/controller/StepsController.java b/sonic-server-controller/src/main/java/org/cloud/sonic/controller/controller/StepsController.java index ebdc556b..8c97e375 100644 --- a/sonic-server-controller/src/main/java/org/cloud/sonic/controller/controller/StepsController.java +++ b/sonic-server-controller/src/main/java/org/cloud/sonic/controller/controller/StepsController.java @@ -161,11 +161,13 @@ public RespModel> searchFindAll(@RequestParam(name = "proj @Operation(summary = "复制步骤", description = "测试用例复制其中一个步骤") @Parameters(value = { @Parameter(name = "id", description = "用例中需要被复制步骤Id"), + @Parameter(name = "toLast", description = "是否拷贝用例到最后一行", example = "true"), }) @GetMapping("/copy/steps") - public RespModel copyStepsIdByCase(@RequestParam(name = "id") int stepId) { - stepsService.copyStepsIdByCase(stepId); - + public RespModel copyStepsIdByCase(@RequestParam(name = "id") int stepId, + @RequestParam(name = "toLast", defaultValue = "true", required = false) + boolean toLast) { + stepsService.copyStepsIdByCase(stepId, toLast); return new RespModel<>(RespEnum.COPY_OK); } diff --git a/sonic-server-controller/src/main/java/org/cloud/sonic/controller/services/StepsService.java b/sonic-server-controller/src/main/java/org/cloud/sonic/controller/services/StepsService.java index d9872b0a..31f7044d 100644 --- a/sonic-server-controller/src/main/java/org/cloud/sonic/controller/services/StepsService.java +++ b/sonic-server-controller/src/main/java/org/cloud/sonic/controller/services/StepsService.java @@ -69,7 +69,7 @@ public interface StepsService extends IService { CommentPage searchFindByProjectIdAndPlatform(int projectId, int platform, int page, int pageSize, String searchContent); - Boolean copyStepsIdByCase(Integer stepId); + Boolean copyStepsIdByCase(Integer stepId, boolean toLast); Boolean switchStep(int id, int type); diff --git a/sonic-server-controller/src/main/java/org/cloud/sonic/controller/services/impl/StepsServiceImpl.java b/sonic-server-controller/src/main/java/org/cloud/sonic/controller/services/impl/StepsServiceImpl.java index d0f33a5f..1261774e 100644 --- a/sonic-server-controller/src/main/java/org/cloud/sonic/controller/services/impl/StepsServiceImpl.java +++ b/sonic-server-controller/src/main/java/org/cloud/sonic/controller/services/impl/StepsServiceImpl.java @@ -348,8 +348,9 @@ public CommentPage searchFindByProjectIdAndPlatform(int projectId, int @Override @Transactional(rollbackFor = Exception.class) - public Boolean copyStepsIdByCase(Integer stepId) { + public Boolean copyStepsIdByCase(Integer stepId, boolean toLast) { Steps steps = stepsMapper.selectById(stepId); + Integer originSortId = steps.getSort(); StepsDTO stepsCopyDTO = stepsService.handleStep(steps.convertTo(), false); save(steps.setId(null).setSort(stepsMapper.findMaxSort() + 1)); @@ -407,6 +408,17 @@ public Boolean copyStepsIdByCase(Integer stepId) { n++; } } + if (!toLast) { + // 插入到当前步骤的下一行,需要做特殊的排序逻辑处理 + StepSort tempStepSort = new StepSort(); + tempStepSort.setCaseId(steps.getCaseId()); + tempStepSort.setDirection("up"); + // 设置start为当前新增的步骤的sort + tempStepSort.setStartId(steps.getSort()); + // 设置end为之前复制出来的步骤的sort + tempStepSort.setEndId(originSortId); + sortSteps(tempStepSort); + } return true; }