refactor(功能用例): 模块和空白节点组合树增加搜索参数
This commit is contained in:
parent
a5065b7cb4
commit
e52cc072fd
|
@ -32,12 +32,12 @@ public class FunctionalCaseMinderController {
|
||||||
@Resource
|
@Resource
|
||||||
private FunctionalCaseMinderService functionalCaseMinderService;
|
private FunctionalCaseMinderService functionalCaseMinderService;
|
||||||
|
|
||||||
@GetMapping("/tree/{projectId}")
|
@PostMapping("/tree")
|
||||||
@Operation(summary = "用例管理-功能用例-脑图-获取空白节点和模块的组合树")
|
@Operation(summary = "用例管理-功能用例-脑图-获取空白节点和模块的组合树")
|
||||||
@RequiresPermissions(PermissionConstants.FUNCTIONAL_CASE_READ)
|
@RequiresPermissions(PermissionConstants.FUNCTIONAL_CASE_READ)
|
||||||
@CheckOwner(resourceId = "#projectId", resourceType = "project")
|
@CheckOwner(resourceId = "#projectId", resourceType = "project")
|
||||||
public List<BaseTreeNode> getTree(@PathVariable String projectId) {
|
public List<BaseTreeNode> getTree(@Validated @RequestBody FunctionalCaseMindRequest request) {
|
||||||
return functionalCaseMinderService.getTree(projectId);
|
return functionalCaseMinderService.getTree(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/list")
|
@PostMapping("/list")
|
||||||
|
|
|
@ -292,6 +292,7 @@ public class FunctionalCaseMinderService {
|
||||||
List<FunctionalCaseDTO> updateNoticeList = new ArrayList<>();
|
List<FunctionalCaseDTO> updateNoticeList = new ArrayList<>();
|
||||||
List<LogDTO> updateLogDTOS = new ArrayList<>();
|
List<LogDTO> updateLogDTOS = new ArrayList<>();
|
||||||
Map<String, String> newModuleMap = new HashMap<>();
|
Map<String, String> newModuleMap = new HashMap<>();
|
||||||
|
|
||||||
//处理模块
|
//处理模块
|
||||||
dealModule(request, userId, moduleMapper, newModuleMap);
|
dealModule(request, userId, moduleMapper, newModuleMap);
|
||||||
|
|
||||||
|
@ -371,6 +372,11 @@ public class FunctionalCaseMinderService {
|
||||||
//处理空白节点
|
//处理空白节点
|
||||||
dealAdditionalNode(request, userId, additionalNodeMapper, newModuleMap);
|
dealAdditionalNode(request, userId, additionalNodeMapper, newModuleMap);
|
||||||
|
|
||||||
|
//TODO:删除转换的空白节点
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
sqlSession.flushStatements();
|
sqlSession.flushStatements();
|
||||||
SqlSessionUtils.closeSqlSession(sqlSession, sqlSessionFactory);
|
SqlSessionUtils.closeSqlSession(sqlSession, sqlSessionFactory);
|
||||||
|
|
||||||
|
@ -1060,14 +1066,14 @@ public class FunctionalCaseMinderService {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public List<BaseTreeNode> getTree(String projectId) {
|
public List<BaseTreeNode> getTree(FunctionalCaseMindRequest request) {
|
||||||
List<BaseTreeNode> functionalModuleList = extFunctionalCaseModuleMapper.selectBaseByProjectId(projectId);
|
List<BaseTreeNode> functionalModuleList = extFunctionalCaseModuleMapper.selectBaseByProjectId(request.getProjectId());
|
||||||
List<BaseTreeNode> baseTreeNodes = extFunctionalCaseMapper.selectBaseMindNodeByProjectId(projectId);
|
List<BaseTreeNode> baseTreeNodes = extFunctionalCaseMapper.selectBaseMindNodeByProjectId(request.getProjectId());
|
||||||
functionalModuleList.addAll(baseTreeNodes);
|
functionalModuleList.addAll(baseTreeNodes);
|
||||||
return buildTreeAndCountResource(functionalModuleList, true, Translator.get("functional_case.module.default.name"));
|
return buildTreeAndCountResource(functionalModuleList, true, Translator.get("functional_case.module.default.name"), request.getModuleId());
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<BaseTreeNode> buildTreeAndCountResource(List<BaseTreeNode> traverseList, boolean haveVirtualRootNode, String virtualRootName) {
|
public List<BaseTreeNode> buildTreeAndCountResource(List<BaseTreeNode> traverseList, boolean haveVirtualRootNode, String virtualRootName, String moduleId) {
|
||||||
|
|
||||||
List<BaseTreeNode> baseTreeNodeList = new ArrayList<>();
|
List<BaseTreeNode> baseTreeNodeList = new ArrayList<>();
|
||||||
if (haveVirtualRootNode) {
|
if (haveVirtualRootNode) {
|
||||||
|
@ -1097,7 +1103,25 @@ public class FunctionalCaseMinderService {
|
||||||
}
|
}
|
||||||
traverseList = notMatchedList;
|
traverseList = notMatchedList;
|
||||||
}
|
}
|
||||||
return baseTreeNodeList;
|
|
||||||
|
if (StringUtils.isNotBlank(moduleId)) {
|
||||||
|
List<BaseTreeNode> filterList = new ArrayList<>();
|
||||||
|
getFilterList(moduleId, baseTreeNodeList, filterList);
|
||||||
|
return filterList;
|
||||||
|
} else {
|
||||||
|
return baseTreeNodeList;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void getFilterList(String moduleId, List<BaseTreeNode> baseTreeNodeList, List<BaseTreeNode> filterList) {
|
||||||
|
for (BaseTreeNode baseTreeNode : baseTreeNodeList) {
|
||||||
|
if (StringUtils.equalsIgnoreCase(baseTreeNode.getId(), moduleId)) {
|
||||||
|
filterList.add(baseTreeNode);
|
||||||
|
break;
|
||||||
|
} else {
|
||||||
|
getFilterList(moduleId, baseTreeNode.getChildren(), filterList);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public BaseTreeNode getDefaultModule(String name) {
|
public BaseTreeNode getDefaultModule(String name) {
|
||||||
|
|
|
@ -39,7 +39,7 @@ public class FunctionalCaseMinderControllerTest extends BaseTest {
|
||||||
|
|
||||||
public static final String FUNCTIONAL_CASE_EDIT_URL = "/functional/mind/case/edit";
|
public static final String FUNCTIONAL_CASE_EDIT_URL = "/functional/mind/case/edit";
|
||||||
|
|
||||||
public static final String FUNCTIONAL_CASE_NODE_MODULE_URL = "/functional/mind/case/tree/";
|
public static final String FUNCTIONAL_CASE_NODE_MODULE_URL = "/functional/mind/case/tree";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -265,12 +265,19 @@ public class FunctionalCaseMinderControllerTest extends BaseTest {
|
||||||
@Test
|
@Test
|
||||||
@Order(3)
|
@Order(3)
|
||||||
public void testGetCaseModuleNodeList() throws Exception {
|
public void testGetCaseModuleNodeList() throws Exception {
|
||||||
MvcResult mvcResultPage = this.requestGetWithOkAndReturn(FUNCTIONAL_CASE_NODE_MODULE_URL+"project-case-minder-test");
|
FunctionalCaseMindRequest request = new FunctionalCaseMindRequest();
|
||||||
|
request.setProjectId("project-case-minder-test");
|
||||||
|
MvcResult mvcResultPage = this.requestPostWithOkAndReturn(FUNCTIONAL_CASE_NODE_MODULE_URL, request);
|
||||||
String contentAsString = mvcResultPage.getResponse().getContentAsString(StandardCharsets.UTF_8);
|
String contentAsString = mvcResultPage.getResponse().getContentAsString(StandardCharsets.UTF_8);
|
||||||
ResultHolder resultHolder = JSON.parseObject(contentAsString, ResultHolder.class);
|
ResultHolder resultHolder = JSON.parseObject(contentAsString, ResultHolder.class);
|
||||||
List<BaseTreeNode> baseTreeNodes = JSON.parseArray(JSON.toJSONString(resultHolder.getData()), BaseTreeNode.class);
|
List<BaseTreeNode> baseTreeNodes = JSON.parseArray(JSON.toJSONString(resultHolder.getData()), BaseTreeNode.class);
|
||||||
Assertions.assertNotNull(baseTreeNodes);
|
Assertions.assertNotNull(baseTreeNodes);
|
||||||
System.out.println(baseTreeNodes);
|
request.setModuleId("TEST_MINDER_MODULE_ID_GYQ");
|
||||||
|
mvcResultPage = this.requestPostWithOkAndReturn(FUNCTIONAL_CASE_NODE_MODULE_URL, request);
|
||||||
|
contentAsString = mvcResultPage.getResponse().getContentAsString(StandardCharsets.UTF_8);
|
||||||
|
resultHolder = JSON.parseObject(contentAsString, ResultHolder.class);
|
||||||
|
baseTreeNodes = JSON.parseArray(JSON.toJSONString(resultHolder.getData()), BaseTreeNode.class);
|
||||||
|
Assertions.assertNotNull(baseTreeNodes);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
Loading…
Reference in New Issue