diff --git a/test-track/backend/src/main/java/io/metersphere/base/mapper/ext/ExtIssuesMapper.xml b/test-track/backend/src/main/java/io/metersphere/base/mapper/ext/ExtIssuesMapper.xml
index a1e637fa69..2458b79a45 100644
--- a/test-track/backend/src/main/java/io/metersphere/base/mapper/ext/ExtIssuesMapper.xml
+++ b/test-track/backend/src/main/java/io/metersphere/base/mapper/ext/ExtIssuesMapper.xml
@@ -88,7 +88,10 @@
select count(1) as `count`, if(i.platform = 'Local', cfi.value, i.platform_status) as statusValue, i.platform
from issues i
inner join project p
- on i.project_id = p.id and p.workspace_id = #{request.workspaceId}
+ on i.project_id = p.id and p.workspace_id = #{request.workspaceId} and
+ p.id IN (SELECT source_id
+ FROM user_group
+ WHERE user_id = #{request.creator})
left join custom_field_issues cfi
on i.id = cfi.resource_id and field_id in (select cf.id
from custom_field cf
diff --git a/workstation/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiScenarioMapper.xml b/workstation/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiScenarioMapper.xml
index 8b0c96f230..bc565f8bb2 100644
--- a/workstation/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiScenarioMapper.xml
+++ b/workstation/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiScenarioMapper.xml
@@ -243,6 +243,12 @@
AND create_time >= #{request.scheduleCreateTime}
)
+
+ AND project.id in
+
+ #{itemId}
+
+
AND api_scenario.id in
diff --git a/workstation/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiTestCaseMapper.xml b/workstation/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiTestCaseMapper.xml
index a4c8e7ef56..88860a117d 100644
--- a/workstation/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiTestCaseMapper.xml
+++ b/workstation/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiTestCaseMapper.xml
@@ -277,7 +277,6 @@
inner join project on api_test_case.project_id = project.id
inner JOIN api_definition a ON api_test_case.api_definition_id = a.id
- and a.latest = 1
+
+ AND project.id in
+
+ #{itemId}
+
+
AND project.workspace_id = #{request.workspaceId}
diff --git a/workstation/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestCaseMapper.xml b/workstation/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestCaseMapper.xml
index ab83427d20..f4dd58bbdd 100644
--- a/workstation/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestCaseMapper.xml
+++ b/workstation/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestCaseMapper.xml
@@ -467,6 +467,12 @@
and test_case.project_id = #{request.projectId}
+
+ AND project.id in
+
+ #{itemId}
+
+
and test_case.id not in (select distinct test_case_test.test_case_id from test_case_test)
diff --git a/workstation/backend/src/main/java/io/metersphere/request/api/ApiScenarioRequest.java b/workstation/backend/src/main/java/io/metersphere/request/api/ApiScenarioRequest.java
index 47e96c5254..4ede629d9f 100644
--- a/workstation/backend/src/main/java/io/metersphere/request/api/ApiScenarioRequest.java
+++ b/workstation/backend/src/main/java/io/metersphere/request/api/ApiScenarioRequest.java
@@ -4,6 +4,9 @@ import io.metersphere.request.BaseQueryRequest;
import lombok.Getter;
import lombok.Setter;
+import java.util.ArrayList;
+import java.util.List;
+
@Getter
@Setter
public class ApiScenarioRequest extends BaseQueryRequest {
@@ -35,4 +38,5 @@ public class ApiScenarioRequest extends BaseQueryRequest {
//测试计划关联场景过滤掉步骤为0的场景
private String stepTotal;
+ private List projectIdList = new ArrayList<>();
}
diff --git a/workstation/backend/src/main/java/io/metersphere/request/api/ApiTestCaseRequest.java b/workstation/backend/src/main/java/io/metersphere/request/api/ApiTestCaseRequest.java
index cb58800f58..df5541e5d6 100644
--- a/workstation/backend/src/main/java/io/metersphere/request/api/ApiTestCaseRequest.java
+++ b/workstation/backend/src/main/java/io/metersphere/request/api/ApiTestCaseRequest.java
@@ -5,6 +5,7 @@ import io.metersphere.request.OrderRequest;
import lombok.Getter;
import lombok.Setter;
+import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@@ -73,4 +74,6 @@ public class ApiTestCaseRequest extends BaseQueryRequest {
//全选
private boolean selectAll;
+
+ private List projectIdList = new ArrayList<>();
}
diff --git a/workstation/backend/src/main/java/io/metersphere/request/track/QueryTestCaseRequest.java b/workstation/backend/src/main/java/io/metersphere/request/track/QueryTestCaseRequest.java
index f8cf21f5c2..5e6ad30fad 100644
--- a/workstation/backend/src/main/java/io/metersphere/request/track/QueryTestCaseRequest.java
+++ b/workstation/backend/src/main/java/io/metersphere/request/track/QueryTestCaseRequest.java
@@ -4,6 +4,7 @@ import io.metersphere.request.BaseQueryRequest;
import lombok.Getter;
import lombok.Setter;
+import java.util.ArrayList;
import java.util.List;
@Getter
@@ -63,4 +64,6 @@ public class QueryTestCaseRequest extends BaseQueryRequest {
private Boolean toBeUpdated;
private String apiCoverage;
private String scenarioCoverage;
+
+ private List projectIdList = new ArrayList<>();
}
diff --git a/workstation/backend/src/main/java/io/metersphere/request/track/QueryTestPlanRequest.java b/workstation/backend/src/main/java/io/metersphere/request/track/QueryTestPlanRequest.java
index 14a72a6a70..c90b10fcef 100644
--- a/workstation/backend/src/main/java/io/metersphere/request/track/QueryTestPlanRequest.java
+++ b/workstation/backend/src/main/java/io/metersphere/request/track/QueryTestPlanRequest.java
@@ -4,6 +4,7 @@ import io.metersphere.request.OrderRequest;
import lombok.Getter;
import lombok.Setter;
+import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@@ -15,4 +16,5 @@ public class QueryTestPlanRequest extends TestPlanRequest {
private List orders;
private Map> filters;
private Map combine;
+ private List projectIdList = new ArrayList<>();
}
diff --git a/workstation/backend/src/main/java/io/metersphere/workstation/service/WorkstationService.java b/workstation/backend/src/main/java/io/metersphere/workstation/service/WorkstationService.java
index c69b46d829..579a622a8a 100644
--- a/workstation/backend/src/main/java/io/metersphere/workstation/service/WorkstationService.java
+++ b/workstation/backend/src/main/java/io/metersphere/workstation/service/WorkstationService.java
@@ -12,25 +12,21 @@ import io.metersphere.commons.utils.SessionUtils;
import io.metersphere.request.ApiSyncCaseRequest;
import io.metersphere.request.ProjectRequest;
import io.metersphere.request.api.ApiScenarioRequest;
+import io.metersphere.request.api.ApiTestCaseRequest;
import io.metersphere.request.track.QueryTestCaseRequest;
import io.metersphere.request.track.QueryTestPlanRequest;
-import io.metersphere.request.api.ApiTestCaseRequest;
+import jakarta.annotation.Resource;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
-import jakarta.annotation.Resource;
-import java.text.SimpleDateFormat;
import java.time.DayOfWeek;
import java.time.LocalDate;
import java.time.ZoneId;
-import java.time.temporal.TemporalAccessor;
import java.time.temporal.TemporalField;
import java.time.temporal.WeekFields;
import java.util.*;
-import java.util.stream.Collectors;
-import java.util.stream.Stream;
import static io.metersphere.workstation.util.ShareUtil.getTimeMills;
@@ -77,7 +73,7 @@ public class WorkstationService {
createTime = startDayOfWeek.getTime();
}
String userId = SessionUtils.getUserId();
- //build query condition object
+
QueryTestPlanRequest testPlanRequest = new QueryTestPlanRequest();
testPlanRequest.setUserId(userId);
testPlanRequest.setWorkspaceId(SessionUtils.getCurrentWorkspaceId());
@@ -89,7 +85,7 @@ public class WorkstationService {
if (isWeek) {
apiTestCaseRequest.setCreateTime(createTime);
}
- //@see io/metersphere/base/mapper/ext/ExtApiTestCaseMapper.xml:103
+
Map combine = new HashMap<>(2);
Map operatorValue = new HashMap<>(2);
operatorValue.put("operator", "current user");
@@ -109,6 +105,19 @@ public class WorkstationService {
if (isWeek) {
testCaseRequest.setCreateTime(createTime);
}
+
+ ProjectRequest projectRequest = new ProjectRequest();
+ projectRequest.setWorkspaceId(SessionUtils.getCurrentWorkspaceId());
+ projectRequest.setUserId(userId);
+ List projects = baseProjectMapper.getUserProject(projectRequest);
+ if (CollectionUtils.isNotEmpty(projects)) {
+ List projectIds = projects.stream().map(Project::getId).toList();
+ apiScenarioRequest.setProjectIdList(projectIds);
+ apiTestCaseRequest.setProjectIdList(projectIds);
+ testCaseRequest.setProjectIdList(projectIds);
+ testPlanRequest.setProjectIdList(projectIds);
+ }
+
//query db
int apiScenarioCaseCount = extApiScenarioMapper.listModule(apiScenarioRequest);
int apiTestCaseCount = extApiTestCaseMapper.moduleCount(apiTestCaseRequest);
@@ -124,12 +133,17 @@ public class WorkstationService {
}
- public Map getFollowTotalCount(String workstationId){
+ public Map getFollowTotalCount(String workstationId) {
String userId = SessionUtils.getUserId();
- List projectIds = extProjectMapper.getProjectIdByWorkspaceId(workstationId);
- if (CollectionUtils.isEmpty(projectIds)) {
+
+ ProjectRequest projectRequest = new ProjectRequest();
+ projectRequest.setWorkspaceId(workstationId);
+ projectRequest.setUserId(userId);
+ List projects = baseProjectMapper.getUserProject(projectRequest);
+ if (CollectionUtils.isEmpty(projects)) {
return null;
}
+ List projectIds = projects.stream().map(Project::getId).toList();
int caseFollowCount = extTestCaseMapper.getCountFollow(projectIds, userId);
int planFollowCount = extTestPlanMapper.getCountFollow(projectIds, userId);
int reviewFollowCount = extTestCaseReviewMapper.getCountFollow(projectIds, userId);
@@ -246,10 +260,14 @@ public class WorkstationService {
public Integer getIssueWeekCount(String workstationId) {
String userId = SessionUtils.getUserId();
- List projectIds = extProjectMapper.getProjectIdByWorkspaceId(workstationId);
- if (CollectionUtils.isEmpty(projectIds)) {
+ ProjectRequest projectRequest = new ProjectRequest();
+ projectRequest.setWorkspaceId(workstationId);
+ projectRequest.setUserId(userId);
+ List projects = baseProjectMapper.getUserProject(projectRequest);
+ if (CollectionUtils.isEmpty(projects)) {
return null;
}
+ List projectIds = projects.stream().map(Project::getId).toList();
Date startDayOfWeek = getStartDayOfWeek();
Long createTime = startDayOfWeek.getTime();
return extIssuesMapper.getCountCreat(projectIds, userId, createTime);