fix(测试跟踪): 公共用例库显示了全部工作空间的用例
--bug=1015070 --user=陈建星 【测试跟踪】功能用例页面-查看公共用例库-左侧模块树显示所有工作空间的的公共用例数 https://www.tapd.cn/55049933/s/1205022
This commit is contained in:
parent
02dada8275
commit
8e575df95f
|
@ -162,4 +162,6 @@ public interface ExtTestCaseMapper {
|
||||||
List<Map<String, Object>> moduleExtraNodeCount(@Param("nodeIds") List<String> nodeIds);
|
List<Map<String, Object>> moduleExtraNodeCount(@Param("nodeIds") List<String> nodeIds);
|
||||||
|
|
||||||
int bathUpdateByCondition(@Param("request") QueryTestCaseRequest condition, @Param("record") TestCaseWithBLOBs testCaseWithBLOBs);
|
int bathUpdateByCondition(@Param("request") QueryTestCaseRequest condition, @Param("record") TestCaseWithBLOBs testCaseWithBLOBs);
|
||||||
|
|
||||||
|
List<TestCaseNodeDTO> getWorkspaceCountNodes(@Param("request") QueryTestCaseRequest request);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1255,4 +1255,13 @@
|
||||||
</foreach>
|
</foreach>
|
||||||
GROUP BY parent_id
|
GROUP BY parent_id
|
||||||
</select>
|
</select>
|
||||||
|
<select id="getWorkspaceCountNodes" resultType="io.metersphere.track.dto.TestCaseNodeDTO">
|
||||||
|
select tcn.id, count(*) as caseNum, test_case.project_id
|
||||||
|
from test_case_node tcn
|
||||||
|
inner join test_case on test_case.node_id = tcn.id
|
||||||
|
inner join project p on p.id = test_case.project_id
|
||||||
|
<include refid="queryWhereCondition"/>
|
||||||
|
and p.workspace_id = #{request.workspaceId}
|
||||||
|
group by test_case.node_id;
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|
|
@ -112,6 +112,12 @@ public class NodeTreeService<T extends TreeNodeDTO> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户测试计划评审或者公共用例库查询多个项目的模块
|
||||||
|
* @param countModules 带有用例的节点的信息
|
||||||
|
* @param getProjectModulesFunc 根据 projectIds 获取多个项目下的模块
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
public List<T> getNodeTreeWithPruningTree(List<T> countModules,
|
public List<T> getNodeTreeWithPruningTree(List<T> countModules,
|
||||||
Function<List<String>, List<T>> getProjectModulesFunc) {
|
Function<List<String>, List<T>> getProjectModulesFunc) {
|
||||||
if (org.springframework.util.CollectionUtils.isEmpty(countModules)) {
|
if (org.springframework.util.CollectionUtils.isEmpty(countModules)) {
|
||||||
|
@ -127,11 +133,12 @@ public class NodeTreeService<T extends TreeNodeDTO> {
|
||||||
ProjectService projectService = CommonBeanFactory.getBean(ProjectService.class);
|
ProjectService projectService = CommonBeanFactory.getBean(ProjectService.class);
|
||||||
List<Project> projects = projectService.getProjectByIds(new ArrayList<>(projectIds));
|
List<Project> projects = projectService.getProjectByIds(new ArrayList<>(projectIds));
|
||||||
|
|
||||||
|
// 项目->对应项目下的模块
|
||||||
Map<String, List<T>> projectModuleMap = getProjectModulesFunc.apply(projectIds)
|
Map<String, List<T>> projectModuleMap = getProjectModulesFunc.apply(projectIds)
|
||||||
.stream()
|
.stream()
|
||||||
.collect(Collectors.groupingBy(TreeNodeDTO::getProjectId));
|
.collect(Collectors.groupingBy(TreeNodeDTO::getProjectId));
|
||||||
|
|
||||||
// 模块与用例数的映射
|
// 模块->用例数
|
||||||
Map<String, Integer> countMap = countModules.stream()
|
Map<String, Integer> countMap = countModules.stream()
|
||||||
.collect(Collectors.toMap(TreeNodeDTO::getId, TreeNodeDTO::getCaseNum));
|
.collect(Collectors.toMap(TreeNodeDTO::getId, TreeNodeDTO::getCaseNum));
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,6 @@ import io.metersphere.notice.annotation.SendNotice;
|
||||||
import io.metersphere.service.CheckPermissionService;
|
import io.metersphere.service.CheckPermissionService;
|
||||||
import io.metersphere.service.FileService;
|
import io.metersphere.service.FileService;
|
||||||
import io.metersphere.track.dto.TestCaseDTO;
|
import io.metersphere.track.dto.TestCaseDTO;
|
||||||
import io.metersphere.track.dto.TestCaseNodeDTO;
|
|
||||||
import io.metersphere.track.request.testcase.*;
|
import io.metersphere.track.request.testcase.*;
|
||||||
import io.metersphere.track.request.testplan.FileOperationRequest;
|
import io.metersphere.track.request.testplan.FileOperationRequest;
|
||||||
import io.metersphere.track.request.testplan.LoadCaseRequest;
|
import io.metersphere.track.request.testplan.LoadCaseRequest;
|
||||||
|
@ -74,12 +73,6 @@ public class TestCaseController {
|
||||||
return PageUtils.setPageInfo(page, testCaseService.publicListTestCase(request));
|
return PageUtils.setPageInfo(page, testCaseService.publicListTestCase(request));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@PostMapping("/public/case/node")
|
|
||||||
public List<TestCaseNodeDTO> getPublicCaseNode(@RequestBody QueryTestCaseRequest request) {
|
|
||||||
return testCaseService.getPublicCaseNode(request);
|
|
||||||
}
|
|
||||||
|
|
||||||
@GetMapping("/list/{projectId}")
|
@GetMapping("/list/{projectId}")
|
||||||
@RequiresPermissions("PROJECT_TRACK_CASE:READ")
|
@RequiresPermissions("PROJECT_TRACK_CASE:READ")
|
||||||
public List<TestCaseDTO> list(@PathVariable String projectId) {
|
public List<TestCaseDTO> list(@PathVariable String projectId) {
|
||||||
|
|
|
@ -74,6 +74,11 @@ public class TestCaseNodeController {
|
||||||
return testCaseNodeService.getNodeByPlanId(planId, Optional.ofNullable(request).orElse(new QueryTestPlanCaseRequest()));
|
return testCaseNodeService.getNodeByPlanId(planId, Optional.ofNullable(request).orElse(new QueryTestPlanCaseRequest()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PostMapping("/list/public/{workspaceId}")
|
||||||
|
public List<TestCaseNodeDTO> getPublicCaseNode(@PathVariable String workspaceId, @RequestBody QueryTestCaseRequest request) {
|
||||||
|
return testCaseNodeService.getPublicCaseNode(workspaceId, request);
|
||||||
|
}
|
||||||
|
|
||||||
@PostMapping("/list/plan/relate")
|
@PostMapping("/list/plan/relate")
|
||||||
public List<TestCaseNodeDTO> getRelatePlanNodes(@RequestBody QueryTestCaseRequest request) {
|
public List<TestCaseNodeDTO> getRelatePlanNodes(@RequestBody QueryTestCaseRequest request) {
|
||||||
checkPermissionService.checkTestPlanOwner(request.getPlanId());
|
checkPermissionService.checkTestPlanOwner(request.getPlanId());
|
||||||
|
|
|
@ -4,7 +4,9 @@ package io.metersphere.track.service;
|
||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
import com.google.common.util.concurrent.AtomicDouble;
|
import com.google.common.util.concurrent.AtomicDouble;
|
||||||
import io.metersphere.base.domain.*;
|
import io.metersphere.base.domain.*;
|
||||||
import io.metersphere.base.mapper.*;
|
import io.metersphere.base.mapper.ProjectMapper;
|
||||||
|
import io.metersphere.base.mapper.TestCaseMapper;
|
||||||
|
import io.metersphere.base.mapper.TestCaseNodeMapper;
|
||||||
import io.metersphere.base.mapper.ext.ExtTestCaseMapper;
|
import io.metersphere.base.mapper.ext.ExtTestCaseMapper;
|
||||||
import io.metersphere.base.mapper.ext.ExtTestCaseNodeMapper;
|
import io.metersphere.base.mapper.ext.ExtTestCaseNodeMapper;
|
||||||
import io.metersphere.base.mapper.ext.ExtTestPlanTestCaseMapper;
|
import io.metersphere.base.mapper.ext.ExtTestPlanTestCaseMapper;
|
||||||
|
@ -22,7 +24,6 @@ import io.metersphere.log.vo.DetailColumn;
|
||||||
import io.metersphere.log.vo.OperatingLogDetails;
|
import io.metersphere.log.vo.OperatingLogDetails;
|
||||||
import io.metersphere.log.vo.api.ModuleReference;
|
import io.metersphere.log.vo.api.ModuleReference;
|
||||||
import io.metersphere.service.NodeTreeService;
|
import io.metersphere.service.NodeTreeService;
|
||||||
import io.metersphere.service.ProjectService;
|
|
||||||
import io.metersphere.track.dto.TestCaseDTO;
|
import io.metersphere.track.dto.TestCaseDTO;
|
||||||
import io.metersphere.track.dto.TestCaseNodeDTO;
|
import io.metersphere.track.dto.TestCaseNodeDTO;
|
||||||
import io.metersphere.track.dto.TestPlanCaseDTO;
|
import io.metersphere.track.dto.TestPlanCaseDTO;
|
||||||
|
@ -34,7 +35,6 @@ import org.apache.ibatis.session.ExecutorType;
|
||||||
import org.apache.ibatis.session.SqlSession;
|
import org.apache.ibatis.session.SqlSession;
|
||||||
import org.apache.ibatis.session.SqlSessionFactory;
|
import org.apache.ibatis.session.SqlSessionFactory;
|
||||||
import org.mybatis.spring.SqlSessionUtils;
|
import org.mybatis.spring.SqlSessionUtils;
|
||||||
import org.springframework.context.annotation.Lazy;
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.util.CollectionUtils;
|
import org.springframework.util.CollectionUtils;
|
||||||
|
@ -54,8 +54,6 @@ public class TestCaseNodeService extends NodeTreeService<TestCaseNodeDTO> {
|
||||||
@Resource
|
@Resource
|
||||||
TestCaseMapper testCaseMapper;
|
TestCaseMapper testCaseMapper;
|
||||||
@Resource
|
@Resource
|
||||||
TestPlanMapper testPlanMapper;
|
|
||||||
@Resource
|
|
||||||
ExtTestPlanTestCaseMapper extTestPlanTestCaseMapper;
|
ExtTestPlanTestCaseMapper extTestPlanTestCaseMapper;
|
||||||
@Resource
|
@Resource
|
||||||
ExtTestCaseMapper extTestCaseMapper;
|
ExtTestCaseMapper extTestCaseMapper;
|
||||||
|
@ -66,12 +64,7 @@ public class TestCaseNodeService extends NodeTreeService<TestCaseNodeDTO> {
|
||||||
@Resource
|
@Resource
|
||||||
ProjectMapper projectMapper;
|
ProjectMapper projectMapper;
|
||||||
@Resource
|
@Resource
|
||||||
TestCaseReviewMapper testCaseReviewMapper;
|
|
||||||
@Resource
|
|
||||||
ExtTestReviewCaseMapper extTestReviewCaseMapper;
|
ExtTestReviewCaseMapper extTestReviewCaseMapper;
|
||||||
@Lazy
|
|
||||||
@Resource
|
|
||||||
ProjectService projectService;
|
|
||||||
|
|
||||||
public TestCaseNodeService() {
|
public TestCaseNodeService() {
|
||||||
super(TestCaseNodeDTO.class);
|
super(TestCaseNodeDTO.class);
|
||||||
|
@ -276,19 +269,15 @@ public class TestCaseNodeService extends NodeTreeService<TestCaseNodeDTO> {
|
||||||
return getNodeTreeWithPruningTree(countModules);
|
return getNodeTreeWithPruningTree(countModules);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<TestCaseNodeDTO> getNodeByPlanId(String planId) {
|
public List<TestCaseNodeDTO> getPublicCaseNode(String workspaceId, QueryTestCaseRequest request) {
|
||||||
return this.getNodeByPlanId(planId, new QueryTestPlanCaseRequest());
|
request.setWorkspaceId(workspaceId);
|
||||||
|
request.setProjectId(null);
|
||||||
|
List<TestCaseNodeDTO> countModules = extTestCaseMapper.getWorkspaceCountNodes(request);
|
||||||
|
return getNodeTreeWithPruningTree(countModules);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<TestCaseNodeDTO> getPublicNodeByProjectNode(List<TestCaseNodeDTO> projectNodes, QueryTestCaseRequest request) {
|
public List<TestCaseNodeDTO> getNodeByPlanId(String planId) {
|
||||||
request.setCasePublic(true);
|
return this.getNodeByPlanId(planId, new QueryTestPlanCaseRequest());
|
||||||
for (TestCaseNodeDTO dto : projectNodes) {
|
|
||||||
List<TestCaseNodeDTO> children = this.getNodeTreeByProjectId(dto.getId(), request);
|
|
||||||
dto.setChildren(children);
|
|
||||||
int sum = children.stream().mapToInt(TestCaseNodeDTO::getCaseNum).sum();
|
|
||||||
dto.setCaseNum(sum);
|
|
||||||
}
|
|
||||||
return projectNodes;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<TestCaseNodeDTO> getNodeByReviewId(String reviewId) {
|
public List<TestCaseNodeDTO> getNodeByReviewId(String reviewId) {
|
||||||
|
|
|
@ -46,7 +46,6 @@ import io.metersphere.performance.service.PerformanceTestService;
|
||||||
import io.metersphere.service.*;
|
import io.metersphere.service.*;
|
||||||
import io.metersphere.track.dto.TestCaseCommentDTO;
|
import io.metersphere.track.dto.TestCaseCommentDTO;
|
||||||
import io.metersphere.track.dto.TestCaseDTO;
|
import io.metersphere.track.dto.TestCaseDTO;
|
||||||
import io.metersphere.track.dto.TestCaseNodeDTO;
|
|
||||||
import io.metersphere.track.issue.AbstractIssuePlatform;
|
import io.metersphere.track.issue.AbstractIssuePlatform;
|
||||||
import io.metersphere.track.issue.IssueFactory;
|
import io.metersphere.track.issue.IssueFactory;
|
||||||
import io.metersphere.track.issue.service.XpackIssueService;
|
import io.metersphere.track.issue.service.XpackIssueService;
|
||||||
|
@ -2898,30 +2897,6 @@ public class TestCaseService {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<TestCaseNodeDTO> getPublicCaseNode(QueryTestCaseRequest request) {
|
|
||||||
List<TestCaseNodeDTO> testCaseDTOS = publicProjectNode(request);
|
|
||||||
return testCaseNodeService.getPublicNodeByProjectNode(testCaseDTOS, request);
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<TestCaseNodeDTO> publicProjectNode(QueryTestCaseRequest request) {
|
|
||||||
this.initRequest(request, true);
|
|
||||||
setDefaultOrder(request);
|
|
||||||
if (request.getFilters() != null && !request.getFilters().containsKey("status")) {
|
|
||||||
request.getFilters().put("status", new ArrayList<>(0));
|
|
||||||
}
|
|
||||||
List<TestCaseNodeDTO> testCaseNodeDTOList = new ArrayList<>();
|
|
||||||
List<String> publicProjectIds = extTestCaseMapper.getPublicProjectIdByWorkSpaceId(request);
|
|
||||||
publicProjectIds.forEach(projectId -> {
|
|
||||||
Project project = projectMapper.selectByPrimaryKey(projectId);
|
|
||||||
TestCaseNodeDTO testCaseNodeDTO = new TestCaseNodeDTO();
|
|
||||||
testCaseNodeDTO.setName(project.getName());
|
|
||||||
testCaseNodeDTO.setLabel(project.getName());
|
|
||||||
testCaseNodeDTO.setId(projectId);
|
|
||||||
testCaseNodeDTOList.add(testCaseNodeDTO);
|
|
||||||
});
|
|
||||||
return testCaseNodeDTOList;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void saveRelationshipBatch(TestCaseRelationshipEdgeRequest request) {
|
public void saveRelationshipBatch(TestCaseRelationshipEdgeRequest request) {
|
||||||
List<String> relationshipIds = relationshipEdgeService.getRelationshipIds(request.getId());
|
List<String> relationshipIds = relationshipEdgeService.getRelationshipIds(request.getId());
|
||||||
request.getCondition().setNotInIds(relationshipIds);
|
request.getCondition().setNotInIds(relationshipIds);
|
||||||
|
|
|
@ -3,6 +3,7 @@ import {success} from "@/common/js/message";
|
||||||
import i18n from "@/i18n/i18n";
|
import i18n from "@/i18n/i18n";
|
||||||
import {basePost} from "@/network/base-network";
|
import {basePost} from "@/network/base-network";
|
||||||
import {baseGet} from "./base-network";
|
import {baseGet} from "./base-network";
|
||||||
|
import {getCurrentWorkspaceId} from "@/common/js/utils";
|
||||||
|
|
||||||
export const minderPageInfoMap = new Map();
|
export const minderPageInfoMap = new Map();
|
||||||
|
|
||||||
|
@ -97,7 +98,7 @@ export function getTestReviewCaseNodesByCaseFilter(reviewId, param, callback) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getTestCasePublicNodes(param, callback) {
|
export function getTestCasePublicNodes(param, callback) {
|
||||||
return basePost('/test/case/public/case/node', param, callback);
|
return basePost('/case/node/list/public/' + getCurrentWorkspaceId(), param, callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getRelationshipCase(id, relationshipType, callback) {
|
export function getRelationshipCase(id, relationshipType, callback) {
|
||||||
|
|
Loading…
Reference in New Issue