From fe2e2e3e7367deceafdf71bb2b6da7bc48ca31a1 Mon Sep 17 00:00:00 2001 From: shiziyuan9527 Date: Wed, 19 Feb 2020 22:40:57 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=87=E6=8D=A2=E7=BB=84=E7=BB=87=E5=92=8C?= =?UTF-8?q?=E5=88=87=E6=8D=A2=E5=B7=A5=E4=BD=9C=E7=A9=BA=E9=97=B40.1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/OrganizationController.java | 7 +- .../controller/WorkspaceController.java | 5 ++ .../service/OrganizationService.java | 25 ++++++ .../metersphere/service/WorkspaceService.java | 18 ++++ .../performance/components/HeaderMenus.vue | 84 +++++++++++++++++-- 5 files changed, 133 insertions(+), 6 deletions(-) diff --git a/backend/src/main/java/io/metersphere/controller/OrganizationController.java b/backend/src/main/java/io/metersphere/controller/OrganizationController.java index 1a8cd6795e..390a851db7 100644 --- a/backend/src/main/java/io/metersphere/controller/OrganizationController.java +++ b/backend/src/main/java/io/metersphere/controller/OrganizationController.java @@ -24,7 +24,7 @@ public class OrganizationController { public List getOrganizationList() { return organizationService.getOrganizationList(); } @PostMapping("/list/{goPage}/{pageSize}") - public Pager> getUserList(@PathVariable int goPage, @PathVariable int pageSize) { + public Pager> getOrganizationList(@PathVariable int goPage, @PathVariable int pageSize) { Page page = PageHelper.startPage(goPage, pageSize, true); return PageUtils.setPageInfo(page, organizationService.getOrganizationList()); } @@ -34,4 +34,9 @@ public class OrganizationController { @PostMapping("/update") public void updateOrganization(@RequestBody Organization organization) { organizationService.updateOrganization(organization); } + + @GetMapping("/list/userorg/{userId}") + public List getOrganizationListByUserId(@PathVariable String userId) { + return organizationService.getOrganizationListByUserId(userId); + } } diff --git a/backend/src/main/java/io/metersphere/controller/WorkspaceController.java b/backend/src/main/java/io/metersphere/controller/WorkspaceController.java index 3d0f98bc8f..dc3291c9ff 100644 --- a/backend/src/main/java/io/metersphere/controller/WorkspaceController.java +++ b/backend/src/main/java/io/metersphere/controller/WorkspaceController.java @@ -45,4 +45,9 @@ public class WorkspaceController { Page page = PageHelper.startPage(goPage, pageSize, true); return PageUtils.setPageInfo(page, workspaceService.getWorkspaceList()); } + + @GetMapping("/list/userworkspace/{userId}") + public List getWorkspaceListByUserId(@PathVariable String userId) { + return workspaceService.getWorkspaceListByUserId(userId); + } } diff --git a/backend/src/main/java/io/metersphere/service/OrganizationService.java b/backend/src/main/java/io/metersphere/service/OrganizationService.java index da5362d072..b801947e35 100644 --- a/backend/src/main/java/io/metersphere/service/OrganizationService.java +++ b/backend/src/main/java/io/metersphere/service/OrganizationService.java @@ -1,11 +1,17 @@ package io.metersphere.service; import io.metersphere.base.domain.Organization; +import io.metersphere.base.domain.OrganizationExample; import io.metersphere.base.mapper.OrganizationMapper; +import io.metersphere.base.mapper.UserRoleMapper; +import io.metersphere.base.mapper.ext.ExtUserRoleMapper; +import io.metersphere.dto.UserRoleHelpDTO; +import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; +import java.util.ArrayList; import java.util.List; import java.util.UUID; @@ -15,6 +21,10 @@ public class OrganizationService { @Resource private OrganizationMapper organizationMapper; + @Resource + private UserRoleMapper userRoleMapper; + @Resource + private ExtUserRoleMapper extUserRoleMapper; public Organization addOrganization(Organization organization) { long currentTimeMillis = System.currentTimeMillis(); @@ -37,4 +47,19 @@ public class OrganizationService { organization.setUpdateTime(System.currentTimeMillis()); organizationMapper.updateByPrimaryKeySelective(organization); } + + public List getOrganizationListByUserId(String userId) { + List userRoleHelpList = extUserRoleMapper.getUserRoleHelpList(userId); + List list = new ArrayList<>(); + userRoleHelpList.forEach(r -> { + if (StringUtils.isEmpty(r.getParentId())) { + list.add(r.getSourceId()); + } else { + list.add(r.getParentId()); + } + }); + OrganizationExample organizationExample = new OrganizationExample(); + organizationExample.createCriteria().andIdIn(list); + return organizationMapper.selectByExample(organizationExample); + } } diff --git a/backend/src/main/java/io/metersphere/service/WorkspaceService.java b/backend/src/main/java/io/metersphere/service/WorkspaceService.java index a5788652c3..d47f365b1c 100644 --- a/backend/src/main/java/io/metersphere/service/WorkspaceService.java +++ b/backend/src/main/java/io/metersphere/service/WorkspaceService.java @@ -4,8 +4,10 @@ import io.metersphere.base.domain.UserRole; import io.metersphere.base.domain.Workspace; import io.metersphere.base.domain.WorkspaceExample; import io.metersphere.base.mapper.WorkspaceMapper; +import io.metersphere.base.mapper.ext.ExtUserRoleMapper; import io.metersphere.commons.constants.RoleConstants; import io.metersphere.commons.exception.MSException; +import io.metersphere.dto.UserRoleHelpDTO; import io.metersphere.user.SessionUser; import io.metersphere.user.SessionUtils; import org.apache.commons.lang3.StringUtils; @@ -13,6 +15,7 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; +import java.util.ArrayList; import java.util.List; import java.util.UUID; import java.util.stream.Collectors; @@ -22,6 +25,8 @@ import java.util.stream.Collectors; public class WorkspaceService { @Resource private WorkspaceMapper workspaceMapper; + @Resource + private ExtUserRoleMapper extUserRoleMapper; public Workspace saveWorkspace(Workspace workspace) { if (StringUtils.isBlank(workspace.getName())) { @@ -73,4 +78,17 @@ public class WorkspaceService { } } + public List getWorkspaceListByUserId(String userId) { + List userRoleHelpList = extUserRoleMapper.getUserRoleHelpList(userId); + List workspaceIds = new ArrayList<>(); + userRoleHelpList.forEach(r -> { + if (!StringUtils.isEmpty(r.getParentId())) { + workspaceIds.add(r.getSourceId()); + } + }); + WorkspaceExample workspaceExample = new WorkspaceExample(); + workspaceExample.createCriteria().andIdIn(workspaceIds); + return workspaceMapper.selectByExample(workspaceExample); + } + } diff --git a/frontend/src/performance/components/HeaderMenus.vue b/frontend/src/performance/components/HeaderMenus.vue index 9565b41f5c..6089b7d88c 100644 --- a/frontend/src/performance/components/HeaderMenus.vue +++ b/frontend/src/performance/components/HeaderMenus.vue @@ -2,11 +2,23 @@ {{ $t("i18n.home") }} - + + + + + - 工作空间1 - 工作空间2 - 显示全部 + @@ -44,10 +56,68 @@ @@ -73,4 +143,8 @@ .el-divider--horizontal { margin: 0; } + + .el-icon-check { + color: #44b349; + }