Skip to content

Commit

Permalink
Merge pull request #354 from dongyi0412/dev
Browse files Browse the repository at this point in the history
fix: 公共步骤关闭还执行 && 无法删除不需要的控件元素 && 公共步骤列表页查看步骤乱序
  • Loading branch information
ZhouYixun authored May 18, 2023
2 parents b3751b5 + 383955e commit 82087f5
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,21 +72,12 @@ public CommentPage<PublicStepsDTO> findByProjectId(int projectId, Page<PublicSte
Page<PublicSteps> page = lambdaQuery().eq(PublicSteps::getProjectId, projectId)
.orderByDesc(PublicSteps::getId)
.page(pageable);
// 业务join,java层拼接结果,虽然麻烦一点,但sql性能确实能优化

List<PublicStepsDTO> publicStepsDTOList = page.getRecords()
.stream().map(TypeConverter::convertTo).collect(Collectors.toList());
Set<Integer> publicStepsIdSet = publicStepsDTOList.stream().map(PublicStepsDTO::getId).collect(Collectors.toSet());
if (publicStepsIdSet.isEmpty()) {
return CommentPage.emptyPage();
}

// publicStepsId -> StepsDTO
Map<Integer, List<StepsDTO>> stepsDTOMap = publicStepsMapper.listStepsByPublicStepsIds(publicStepsIdSet)
.stream().collect(Collectors.groupingBy(StepsDTO::getPublicStepsId));

// 将step填充到public step
publicStepsDTOList.forEach(
e -> e.setSteps(stepsService.handleSteps(stepsDTOMap.get(e.getId()), false))
e -> e.setSteps(findById(e.getId(), false).getSteps())
);

return CommentPage.convertFrom(page, publicStepsDTOList);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@ public CommentPage<TestCasesDTO> findAll(int projectId, int platform, String nam

@Transactional
public TestCasesDTO findCaseDetail(TestCases testCases) {
if (testCases == null){
return new TestCasesDTO().setId(0).setName("unknown");
}

if (testCases.getModuleId() != null && testCases.getModuleId() != 0) {
Modules modules = modulesMapper.selectById(testCases.getModuleId());
if (modules != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ public JSONObject getStep(StepsDTO steps) {
}
publicStepsJson.add(getStep(pubStep));
}
step = (JSONObject) JSONObject.toJSON(steps);
step = (JSONObject) JSONObject.toJSON(steps);
step.put("pubSteps", publicStepsJson);

return step;
Expand All @@ -314,7 +314,7 @@ public JSONObject getStep(StepsDTO steps) {

// 获取步骤结构树
public JSONObject handleSteps(StepsDTO steps) {
JSONObject stepsJsonObj = (JSONObject) JSONObject.toJSON(steps);
JSONObject stepsJsonObj = (JSONObject) JSONObject.toJSON(steps);
if (steps == null) {
return stepsJsonObj;
}
Expand Down Expand Up @@ -344,13 +344,21 @@ public JSONObject handleSteps(StepsDTO steps) {
}
stepsJsonObj.put("text", packagesService.findOne(steps.getProjectId(), steps.getText(), plat));
}

if (CollectionUtils.isEmpty(steps.getChildSteps())) {
return stepsJsonObj;
}

JSONArray childStepJsonObjs = new JSONArray();
List<StepsDTO> childSteps = steps.getChildSteps();

for (StepsDTO childStep : childSteps) {
if (childStep.getDisabled() == 1) {
continue;
}

JSONObject childStepJsonObj = handleSteps(childStep);

childStepJsonObjs.add(childStepJsonObj);
}
stepsJsonObj.put("childSteps", childStepJsonObjs);
Expand Down

0 comments on commit 82087f5

Please sign in to comment.