diff --git a/backend/src/main/java/io/metersphere/controller/WorkspaceController.java b/backend/src/main/java/io/metersphere/controller/WorkspaceController.java index 4d95870d41..840bea814d 100644 --- a/backend/src/main/java/io/metersphere/controller/WorkspaceController.java +++ b/backend/src/main/java/io/metersphere/controller/WorkspaceController.java @@ -55,8 +55,8 @@ public class WorkspaceController { } @GetMapping("/list/orgworkspace/") - public List getWorkspaceListByOrgId() { + public List getWorkspaceListByOrgIdAndUserId() { String currentOrganizationId = SessionUtils.getCurrentOrganizationId(); - return workspaceService.getWorkspaceListByOrgId(currentOrganizationId); + return workspaceService.getWorkspaceListByOrgIdAndUserId(currentOrganizationId); } } diff --git a/backend/src/main/java/io/metersphere/service/WorkspaceService.java b/backend/src/main/java/io/metersphere/service/WorkspaceService.java index 1e76d35d15..d32c4c1c98 100644 --- a/backend/src/main/java/io/metersphere/service/WorkspaceService.java +++ b/backend/src/main/java/io/metersphere/service/WorkspaceService.java @@ -1,8 +1,7 @@ package io.metersphere.service; -import io.metersphere.base.domain.UserRole; -import io.metersphere.base.domain.Workspace; -import io.metersphere.base.domain.WorkspaceExample; +import io.metersphere.base.domain.*; +import io.metersphere.base.mapper.UserRoleMapper; import io.metersphere.base.mapper.WorkspaceMapper; import io.metersphere.base.mapper.ext.ExtUserRoleMapper; import io.metersphere.commons.constants.RoleConstants; @@ -28,6 +27,8 @@ public class WorkspaceService { private WorkspaceMapper workspaceMapper; @Resource private ExtUserRoleMapper extUserRoleMapper; + @Resource + private UserRoleMapper userRoleMapper; public Workspace saveWorkspace(Workspace workspace) { if (StringUtils.isBlank(workspace.getName())) { @@ -100,10 +101,23 @@ public class WorkspaceService { return workspaceMapper.selectByExample(workspaceExample); } - public List getWorkspaceListByOrgId(String orgId) { + public List getWorkspaceListByOrgIdAndUserId(String orgId) { + String useId = SessionUtils.getUser().getId(); WorkspaceExample workspaceExample = new WorkspaceExample(); workspaceExample.createCriteria().andOrganizationIdEqualTo(orgId); - return workspaceMapper.selectByExample(workspaceExample); + List workspaces = workspaceMapper.selectByExample(workspaceExample); + UserRoleExample userRoleExample = new UserRoleExample(); + userRoleExample.createCriteria().andUserIdEqualTo(useId); + List userRoles = userRoleMapper.selectByExample(userRoleExample); + List resultWorkspaceList = new ArrayList<>(); + userRoles.forEach(userRole -> { + workspaces.forEach(workspace -> { + if (StringUtils.equals(userRole.getSourceId(),workspace.getId())) { + resultWorkspaceList.add(workspace); + } + }); + }); + return resultWorkspaceList; } } diff --git a/frontend/src/performance/App.vue b/frontend/src/performance/App.vue index 65b5525fbe..66a0e2e0d8 100644 --- a/frontend/src/performance/App.vue +++ b/frontend/src/performance/App.vue @@ -4,10 +4,10 @@