diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtProjectMapper.xml b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtProjectMapper.xml index 3649e5836d..106506f0ed 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtProjectMapper.xml +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtProjectMapper.xml @@ -66,6 +66,9 @@ and w.id = #{proRequest.workspaceId} + + and p.id = #{proRequest.projectId} + order by diff --git a/backend/src/main/java/io/metersphere/commons/constants/PermissionConstants.java b/backend/src/main/java/io/metersphere/commons/constants/PermissionConstants.java index d6409eab5b..9e1e796806 100644 --- a/backend/src/main/java/io/metersphere/commons/constants/PermissionConstants.java +++ b/backend/src/main/java/io/metersphere/commons/constants/PermissionConstants.java @@ -68,8 +68,12 @@ public class PermissionConstants { public static final String WORKSPACE_TEMPLATE_READ_ISSUE_TEMPLATE = "WORKSPACE_TEMPLATE:READ+ISSUE_TEMPLATE"; public static final String WORKSPACE_TEMPLATE_READ_CUSTOM = "WORKSPACE_TEMPLATE:READ+CUSTOM"; public static final String WORKSPACE_TEMPLATE_READ_REPORT_TEMPLATE = "WORKSPACE_TEMPLATE:READ+REPORT_TEMPLATE"; - - + public static final String WORKSPACE_PROJECT_MANAGER_READ = "WORKSPACE_PROJECT_MANAGER:READ"; + public static final String WORKSPACE_PROJECT_MANAGER_READ_CREATE = "WORKSPACE_PROJECT_MANAGER:READ+CREATE"; + public static final String WORKSPACE_PROJECT_MANAGER_READ_EDIT = "WORKSPACE_PROJECT_MANAGER:READ+EDIT"; + public static final String WORKSPACE_PROJECT_MANAGER_READ_DELETE = "WORKSPACE_PROJECT_MANAGER:READ+DELETE"; + + public static final String PROJECT_USER_READ = "PROJECT_USER:READ"; public static final String PROJECT_USER_READ_CREATE = "PROJECT_USER:READ+CREATE"; public static final String PROJECT_USER_READ_EDIT = "PROJECT_USER:READ+EDIT"; diff --git a/backend/src/main/java/io/metersphere/controller/request/ProjectRequest.java b/backend/src/main/java/io/metersphere/controller/request/ProjectRequest.java index 71c9205661..74acf0bb27 100644 --- a/backend/src/main/java/io/metersphere/controller/request/ProjectRequest.java +++ b/backend/src/main/java/io/metersphere/controller/request/ProjectRequest.java @@ -10,6 +10,7 @@ import java.util.Map; @Setter public class ProjectRequest { private String workspaceId; + private String projectId; private String name; private List orders; private Map> filters; diff --git a/backend/src/main/java/io/metersphere/service/UserService.java b/backend/src/main/java/io/metersphere/service/UserService.java index de64137cc2..5d0d0882bc 100644 --- a/backend/src/main/java/io/metersphere/service/UserService.java +++ b/backend/src/main/java/io/metersphere/service/UserService.java @@ -470,9 +470,7 @@ public class UserService { List workspaces = workspaceService.getWorkspaceListByOrgIdAndUserId(sourceId); if (workspaces.size() > 0) { user.setLastWorkspaceId(workspaces.get(0).getId()); - ProjectExample projectExample = new ProjectExample(); - projectExample.createCriteria().andWorkspaceIdEqualTo(workspaces.get(0).getId()); - List projects = projectMapper.selectByExample(projectExample); + List projects = getProjectListByWsAndUserId(workspaces.get(0).getId()); if (projects.size() > 0) { user.setLastProjectId(projects.get(0).getId()); } else { @@ -484,12 +482,10 @@ public class UserService { } } if (StringUtils.equals("workspace", sign)) { - ProjectExample projectExample = new ProjectExample(); - projectExample.createCriteria().andWorkspaceIdEqualTo(sourceId); - List projects = projectMapper.selectByExample(projectExample); Workspace workspace = workspaceMapper.selectByPrimaryKey(sourceId); user.setLastOrganizationId(workspace.getOrganizationId()); user.setLastWorkspaceId(sourceId); + getProjectListByWsAndUserId(sourceId) if (projects.size() > 0) { user.setLastProjectId(projects.get(0).getId()); } else { @@ -502,6 +498,28 @@ public class UserService { userMapper.updateByPrimaryKeySelective(newUser); } + private List getProjectListByWsAndUserId(String workspaceId) { + String useId = SessionUtils.getUser().getId(); + ProjectExample projectExample = new ProjectExample(); + projectExample.createCriteria().andWorkspaceIdEqualTo(workspaceId); + List projects = projectMapper.selectByExample(projectExample); + + UserGroupExample userGroupExample = new UserGroupExample(); + userGroupExample.createCriteria().andUserIdEqualTo(useId); + List userGroups = userGroupMapper.selectByExample(userGroupExample); + List projectList = new ArrayList<>(); + userGroups.forEach(userGroup -> { + projects.forEach(project -> { + if (StringUtils.equals(userGroup.getSourceId(), project.getId())) { + if (!projectList.contains(project)) { + projectList.add(project); + } + } + }); + }); + return projectList; + } + public UserDTO getUserInfo(String userId) { return getUserDTO(userId); } diff --git a/backend/src/main/resources/db/migration/V85__v1.10_permission_refactor.sql b/backend/src/main/resources/db/migration/V86__v1.10_permission_refactor.sql similarity index 98% rename from backend/src/main/resources/db/migration/V85__v1.10_permission_refactor.sql rename to backend/src/main/resources/db/migration/V86__v1.10_permission_refactor.sql index ea9b4a5a28..de3d903983 100644 --- a/backend/src/main/resources/db/migration/V85__v1.10_permission_refactor.sql +++ b/backend/src/main/resources/db/migration/V86__v1.10_permission_refactor.sql @@ -232,6 +232,14 @@ INSERT INTO user_group_permission (id, group_id, permission_id, module_id) VALUES (uuid(), 'ws_admin', 'WORKSPACE_TEMPLATE:READ+ISSUE_TEMPLATE', 'WORKSPACE_TEMPLATE'); INSERT INTO user_group_permission (id, group_id, permission_id, module_id) VALUES (uuid(), 'ws_admin', 'WORKSPACE_TEMPLATE:READ+CASE_TEMPLATE', 'WORKSPACE_TEMPLATE'); +insert into metersphere_dev.user_group_permission (id, group_id, permission_id, module_id) +values (uuid(), 'ws_admin', 'WORKSPACE_PROJECT_MANAGER:READ', 'WORKSPACE_PROJECT_MANAGER'); +insert into metersphere_dev.user_group_permission (id, group_id, permission_id, module_id) +values (uuid(), 'ws_admin', 'WORKSPACE_PROJECT_MANAGER:READ+CREATE','WORKSPACE_PROJECT_MANAGER'); +insert into metersphere_dev.user_group_permission (id, group_id, permission_id, module_id) +values (uuid(), 'ws_admin', 'WORKSPACE_PROJECT_MANAGER:READ+DELETE', 'WORKSPACE_PROJECT_MANAGER'); +insert into metersphere_dev.user_group_permission (id, group_id, permission_id, module_id) +values (uuid(), 'ws_admin', 'WORKSPACE_PROJECT_MANAGER:READ+EDIT', 'WORKSPACE_PROJECT_MANAGER'); -- 工作空间成员 INSERT INTO user_group_permission (id, group_id, permission_id, module_id) diff --git a/backend/src/main/resources/permission.json b/backend/src/main/resources/permission.json index b90c7fcc86..dbd756dc0f 100644 --- a/backend/src/main/resources/permission.json +++ b/backend/src/main/resources/permission.json @@ -254,6 +254,31 @@ "name": "删除成员", "resourceId": "WORKSPACE_USER" }, + { + "id": "WORKSPACE_PROJECT_MANAGER:READ", + "name": "查询项目", + "resourceId": "WORKSPACE_PROJECT_MANAGER" + }, + { + "id": "WORKSPACE_PROJECT_MANAGER:READ+CREATE", + "name": "创建项目", + "resourceId": "WORKSPACE_PROJECT_MANAGER" + }, + { + "id": "WORKSPACE_PROJECT_MANAGER:READ+EDIT", + "name": "创建项目", + "resourceId": "WORKSPACE_PROJECT_MANAGER" + }, + { + "id": "WORKSPACE_PROJECT_MANAGER:READ+DELETE", + "name": "删除项目", + "resourceId": "WORKSPACE_PROJECT_MANAGER" + }, + { + "id": "WORKSPACE_PROJECT_ENVIRONMENT:READ", + "name": "查询环境", + "resourceId": "WORKSPACE_PROJECT_MANAGER" + }, { "id": "WORKSPACE_TEMPLATE:READ", "name": "查询", @@ -701,6 +726,14 @@ "id": "WORKSPACE_TEMPLATE", "name": "模版设置" }, + { + "id": "WORKSPACE_PROJECT_MANAGER", + "name": "项目管理" + }, + { + "id": "WORKSPACE_PROJECT_ENVIRONMENT", + "name": "环境设置" + }, { "id": "PROJECT_USER", "name": "成员" diff --git a/frontend/src/business/components/api/router.js b/frontend/src/business/components/api/router.js index 74f4046531..4256c60088 100644 --- a/frontend/src/business/components/api/router.js +++ b/frontend/src/business/components/api/router.js @@ -1,4 +1,4 @@ -import MsProject from "@/business/components/settings/project/MsProject"; +import MsProject from "@/business/components/settings/workspace/MsProject"; export default { path: "/api", diff --git a/frontend/src/business/components/common/head/HeaderOrgWs.vue b/frontend/src/business/components/common/head/HeaderOrgWs.vue index b3a025fda3..6229ccc7c0 100644 --- a/frontend/src/business/components/common/head/HeaderOrgWs.vue +++ b/frontend/src/business/components/common/head/HeaderOrgWs.vue @@ -113,36 +113,32 @@ export default { }, methods: { initMenuData() { - if (hasRoles(ROLE_ORG_ADMIN, ROLE_TEST_VIEWER, ROLE_TEST_USER, ROLE_TEST_MANAGER)) { - this.$get("/organization/list/userorg/" + encodeURIComponent(this.currentUserId), response => { - let data = response.data; - this.organizationList = data; - this.orgListCopy = data; - let org = data.filter(r => r.id === this.currentUser.lastOrganizationId); - if (org.length > 0) { - this.currentOrganizationName = org[0].name; - } - }); - } - if (hasRoles(ROLE_TEST_VIEWER, ROLE_TEST_USER, ROLE_TEST_MANAGER)) { - if (!this.currentUser.lastOrganizationId) { - return false; + this.$get("/organization/list/userorg/" + encodeURIComponent(this.currentUserId), response => { + let data = response.data; + this.organizationList = data; + this.orgListCopy = data; + let org = data.filter(r => r.id === this.currentUser.lastOrganizationId); + if (org.length > 0) { + this.currentOrganizationName = org[0].name; } - this.$get("/workspace/list/orgworkspace/", response => { - let data = response.data; - if (data.length === 0) { - this.workspaceList = [{name: this.$t('workspace.none')}]; - } else { - this.workspaceList = data; - this.wsListCopy = data; - let workspace = data.filter(r => r.id === this.currentUser.lastWorkspaceId); - if (workspace.length > 0) { - this.currentWorkspaceName = workspace[0].name; - localStorage.setItem(WORKSPACE_ID, workspace[0].id); - } - } - }); + }); + if (!this.currentUser.lastOrganizationId) { + return false; } + this.$get("/workspace/list/orgworkspace/", response => { + let data = response.data; + if (data.length === 0) { + this.workspaceList = [{name: this.$t('workspace.none')}]; + } else { + this.workspaceList = data; + this.wsListCopy = data; + let workspace = data.filter(r => r.id === this.currentUser.lastWorkspaceId); + if (workspace.length > 0) { + this.currentWorkspaceName = workspace[0].name; + localStorage.setItem(WORKSPACE_ID, workspace[0].id); + } + } + }); }, getCurrentUserInfo() { this.$get("/user/info/" + encodeURIComponent(this.currentUserId), response => { @@ -159,11 +155,11 @@ export default { if (response.data.workspaceId) { localStorage.setItem("workspace_id", response.data.workspaceId); } - if (response.data.lastProjectId) { - localStorage.setItem(PROJECT_ID, response.data.lastProjectId); - } else { - localStorage.removeItem(PROJECT_ID); - } + // if (response.data.lastProjectId) { + // localStorage.setItem(PROJECT_ID, response.data.lastProjectId); + // } else { + // localStorage.removeItem(PROJECT_ID); + // } this.$router.push('/').then(() => { window.location.reload(); }).catch(err => err); @@ -177,11 +173,11 @@ export default { this.$post("/user/switch/source/ws/" + workspaceId, {}, response => { saveLocalStorage(response); localStorage.setItem("workspace_id", workspaceId); - if (response.data.lastProjectId) { - localStorage.setItem(PROJECT_ID, response.data.lastProjectId); - } else { - localStorage.removeItem(PROJECT_ID); - } + // if (response.data.lastProjectId) { + // localStorage.setItem(PROJECT_ID, response.data.lastProjectId); + // } else { + // localStorage.removeItem(PROJECT_ID); + // } this.$router.push('/').then(() => { window.location.reload(); }).catch(err => err); diff --git a/frontend/src/business/components/settings/project/Member.vue b/frontend/src/business/components/settings/project/Member.vue index fb4250398b..8f92bcc4b0 100644 --- a/frontend/src/business/components/settings/project/Member.vue +++ b/frontend/src/business/components/settings/project/Member.vue @@ -120,7 +120,7 @@ export default { initTableData() { let param = {}; param.projectId = this.projectId; - this.$post('/user/project/member/list/' + this.currentPage + "/" + this.pageSize, param, response => { + this.result = this.$post('/user/project/member/list/' + this.currentPage + "/" + this.pageSize, param, response => { let data = response.data; this.tableData = data.listObject; let url = "/user/group/list/project/" + this.projectId; diff --git a/frontend/src/business/components/settings/project/ProjectList.vue b/frontend/src/business/components/settings/project/ProjectList.vue new file mode 100644 index 0000000000..b27e1e61d3 --- /dev/null +++ b/frontend/src/business/components/settings/project/ProjectList.vue @@ -0,0 +1,379 @@ + + + + + diff --git a/frontend/src/business/components/settings/router.js b/frontend/src/business/components/settings/router.js index ee59183435..58d1238594 100644 --- a/frontend/src/business/components/settings/router.js +++ b/frontend/src/business/components/settings/router.js @@ -109,10 +109,20 @@ export default { } }, { - path: 'project/:type', - component: () => import('@/business/components/settings/project/MsProject'), + path: 'project/list/:type', + component: () => import('@/business/components/settings/project/ProjectList'), meta: {project: true, title: 'project.manager', permissions: ['PROJECT_MANAGER:READ']} }, + { + path: 'project/:type', + component: () => import('@/business/components/settings/workspace/MsProject'), + meta: {workspace: true, title: 'project.manager', permissions: ['WORKSPACE_PROJECT_MANAGER:READ']} + }, + { + path: 'wsenvlist', + component: () => import('@/business/components/settings/workspace/WsEnvironmentList'), + meta: {workspace: true, title: 'api_test.environment.environment_config', permissions: ['PROJECT_ENVIRONMENT:READ']} + }, { path: 'envlist', component: () => import('@/business/components/settings/project/EnvironmentList'), diff --git a/frontend/src/business/components/settings/project/MsProject.vue b/frontend/src/business/components/settings/workspace/MsProject.vue similarity index 95% rename from frontend/src/business/components/settings/project/MsProject.vue rename to frontend/src/business/components/settings/workspace/MsProject.vue index c9b1a9d5f2..861e59831d 100644 --- a/frontend/src/business/components/settings/project/MsProject.vue +++ b/frontend/src/business/components/settings/workspace/MsProject.vue @@ -2,7 +2,7 @@