diff --git a/workstation/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiDefinitionMapper.xml b/workstation/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiDefinitionMapper.xml index cd940cd30f..04ef0aca32 100644 --- a/workstation/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiDefinitionMapper.xml +++ b/workstation/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiDefinitionMapper.xml @@ -552,6 +552,7 @@ and ad.status in ('Prepare', 'Underway') and ad.user_id = #{userId,jdbcType=VARCHAR} + and ad.latest = 1 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 92c0c567f6..836d5b054b 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 @@ -4,11 +4,13 @@ package io.metersphere.workstation.service; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.ObjectMapper; +import io.metersphere.base.domain.Project; import io.metersphere.base.domain.ProjectApplication; import io.metersphere.base.mapper.ext.*; import io.metersphere.commons.constants.ExecuteResult; 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.track.QueryTestCaseRequest; import io.metersphere.request.track.QueryTestPlanRequest; @@ -27,6 +29,8 @@ 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; @@ -58,6 +62,9 @@ public class WorkstationService { @Resource private ExtProjectMapper extProjectMapper; + @Resource + private BaseProjectMapper baseProjectMapper; + @Resource private ExtProjectApplicationMapper extProjectApplicationMapper; @@ -152,10 +159,14 @@ public class WorkstationService { public Map getUpcomingTotalCount(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 caseUpcomingCount = extTestCaseMapper.getCountUpcoming(projectIds, userId); int planUpcomingCount = extTestPlanMapper.getCountUpcoming(projectIds, userId); int reviewUpcomingCount = extTestCaseReviewMapper.getCountUpcoming(projectIds, userId);