diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestCaseReviewMapper.java b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestCaseReviewMapper.java index 791044b1bb..85304da4ed 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestCaseReviewMapper.java +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestCaseReviewMapper.java @@ -12,7 +12,7 @@ public interface ExtTestCaseReviewMapper { List list(@Param("request") QueryCaseReviewRequest params); - List listByWorkspaceId(@Param("workspaceId") String workspaceId, @Param("userId") String userId); + List listByWorkspaceId(@Param("workspaceId") String workspaceId, @Param("userId") String userId, @Param("projectId") String projectId); List listRelate(@Param("request") QueryTestReviewRequest request); diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestCaseReviewMapper.xml b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestCaseReviewMapper.xml index 2e0fe80115..af8ef0dd3a 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestCaseReviewMapper.xml +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestCaseReviewMapper.xml @@ -35,6 +35,9 @@ test_case_review.id = test_case_review_project.review_id and test_case_review_project.project_id = project.id and project.workspace_id = #{workspaceId} + + and test_case_review_project.project_id = #{projectId} + and ( (test_case_review_users.review_id = test_case_review.id and test_case_review_users.user_id = #{userId} ) diff --git a/backend/src/main/java/io/metersphere/track/service/TestCaseReviewService.java b/backend/src/main/java/io/metersphere/track/service/TestCaseReviewService.java index c70e971785..aaff1aecdd 100644 --- a/backend/src/main/java/io/metersphere/track/service/TestCaseReviewService.java +++ b/backend/src/main/java/io/metersphere/track/service/TestCaseReviewService.java @@ -199,7 +199,7 @@ public class TestCaseReviewService { } public List recent(String currentWorkspaceId) { - return extTestCaseReviewMapper.listByWorkspaceId(currentWorkspaceId, SessionUtils.getUserId()); + return extTestCaseReviewMapper.listByWorkspaceId(currentWorkspaceId, SessionUtils.getUserId(), SessionUtils.getCurrentProjectId()); } public void editCaseReview(SaveTestCaseReviewRequest testCaseReview) { diff --git a/backend/src/main/java/io/metersphere/track/service/TestCaseService.java b/backend/src/main/java/io/metersphere/track/service/TestCaseService.java index ca463ab9b0..9237735195 100644 --- a/backend/src/main/java/io/metersphere/track/service/TestCaseService.java +++ b/backend/src/main/java/io/metersphere/track/service/TestCaseService.java @@ -220,27 +220,17 @@ public class TestCaseService { public List recentTestPlans(QueryTestCaseRequest request, int count) { - - if (StringUtils.isBlank(request.getWorkspaceId())) { - return null; - } - - ProjectExample projectExample = new ProjectExample(); - projectExample.createCriteria().andWorkspaceIdEqualTo(request.getWorkspaceId()); - - List projectIds = projectMapper.selectByExample(projectExample).stream() - .map(Project::getId).collect(Collectors.toList()); - - if (projectIds.isEmpty()) { - return null; - } - PageHelper.startPage(1, count, true); - TestCaseExample testCaseExample = new TestCaseExample(); - testCaseExample.createCriteria().andProjectIdIn(projectIds).andMaintainerEqualTo(request.getUserId()); - testCaseExample.setOrderByClause("update_time desc, sort desc"); - return testCaseMapper.selectByExample(testCaseExample); + TestCaseExample.Criteria criteria = testCaseExample.createCriteria(); + criteria.andMaintainerEqualTo(request.getUserId()); + String projectId = SessionUtils.getCurrentProjectId(); + if (StringUtils.isNotBlank(projectId)) { + criteria.andProjectIdEqualTo(projectId); + testCaseExample.setOrderByClause("update_time desc, sort desc"); + return testCaseMapper.selectByExample(testCaseExample); + } + return new ArrayList<>(); } public Project getProjectByTestCaseId(String testCaseId) { diff --git a/backend/src/main/java/io/metersphere/track/service/TestPlanService.java b/backend/src/main/java/io/metersphere/track/service/TestPlanService.java index 0df5f31a8b..cf31e92af4 100644 --- a/backend/src/main/java/io/metersphere/track/service/TestPlanService.java +++ b/backend/src/main/java/io/metersphere/track/service/TestPlanService.java @@ -396,11 +396,22 @@ public class TestPlanService { if (StringUtils.isBlank(currentWorkspaceId)) { return null; } - TestPlanExample testPlanTestCaseExample = new TestPlanExample(); - testPlanTestCaseExample.createCriteria().andWorkspaceIdEqualTo(currentWorkspaceId) - .andPrincipalEqualTo(SessionUtils.getUserId()); - testPlanTestCaseExample.setOrderByClause("update_time desc"); - return testPlanMapper.selectByExample(testPlanTestCaseExample); + TestPlanProjectExample testPlanProjectExample = new TestPlanProjectExample(); + TestPlanProjectExample.Criteria criteria = testPlanProjectExample.createCriteria(); + if (StringUtils.isNotBlank(SessionUtils.getCurrentProjectId())) { + criteria.andProjectIdEqualTo(SessionUtils.getCurrentProjectId()); + List testPlanProjects = testPlanProjectMapper.selectByExample(testPlanProjectExample); + if (!CollectionUtils.isEmpty(testPlanProjects)) { + List testPlanIds = testPlanProjects.stream().map(TestPlanProject::getTestPlanId).collect(Collectors.toList()); + TestPlanExample testPlanTestCaseExample = new TestPlanExample(); + testPlanTestCaseExample.createCriteria().andWorkspaceIdEqualTo(currentWorkspaceId) + .andIdIn(testPlanIds) + .andPrincipalEqualTo(SessionUtils.getUserId()); + testPlanTestCaseExample.setOrderByClause("update_time desc"); + return testPlanMapper.selectByExample(testPlanTestCaseExample); + } + } + return new ArrayList<>(); } public List listTestAllPlan(String currentWorkspaceId) {