From 855cb8affb6140ef7d98c94214a596f1800a7c87 Mon Sep 17 00:00:00 2001 From: shiziyuan9527 Date: Mon, 24 May 2021 17:51:23 +0800 Subject: [PATCH] =?UTF-8?q?refactor(=E6=9D=83=E9=99=90=E7=AE=A1=E7=90=86):?= =?UTF-8?q?=20=E6=9D=83=E9=99=90=E8=AE=BE=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../base/mapper/ext/ExtUserGroupMapper.xml | 3 -- .../constants/PermissionConstants.java | 7 +++ .../io/metersphere/service/UserService.java | 2 +- ...sql => V85__v1.10_permission_refactor.sql} | 25 +++++---- backend/src/main/resources/permission.json | 52 +++++++++++++++---- .../common/components/MsTableOperator.vue | 10 +++- .../organization/OrganizationMember.vue | 4 +- .../settings/project/EnvironmentList.vue | 13 ++--- .../components/settings/project/Member.vue | 3 +- .../settings/project/ProjectList.vue | 1 + .../business/components/settings/router.js | 2 +- .../settings/workspace/WsEnvironmentList.vue | 12 ++--- 12 files changed, 92 insertions(+), 42 deletions(-) rename backend/src/main/resources/db/migration/{V86__v1.10_permission_refactor.sql => V85__v1.10_permission_refactor.sql} (96%) diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtUserGroupMapper.xml b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtUserGroupMapper.xml index 7007563690..1ccd3a5d38 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtUserGroupMapper.xml +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtUserGroupMapper.xml @@ -22,9 +22,6 @@ ON user_group.user_id = `user`.id WHERE user_group.source_id in ( - SELECT id FROM workspace w - WHERE w.organization_id = #{orgMember.organizationId} - UNION SELECT #{orgMember.organizationId} AS id FROM dual ) 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 9e1e796806..8171880db3 100644 --- a/backend/src/main/java/io/metersphere/commons/constants/PermissionConstants.java +++ b/backend/src/main/java/io/metersphere/commons/constants/PermissionConstants.java @@ -72,6 +72,13 @@ public class PermissionConstants { 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 WORKSPACE_PROJECT_ENVIRONMENT_READ = "WORKSPACE_PROJECT_ENVIRONMENT:READ"; + public static final String WORKSPACE_PROJECT_ENVIRONMENT_READ_CREATE = "WORKSPACE_PROJECT_ENVIRONMENT:READ+CREATE"; + public static final String WORKSPACE_PROJECT_ENVIRONMENT_READ_EDIT = "WORKSPACE_PROJECT_ENVIRONMENT:READ+EDIT"; + public static final String WORKSPACE_PROJECT_ENVIRONMENT_READ_DELETE = "WORKSPACE_PROJECT_ENVIRONMENT:READ+DELETE"; + public static final String WORKSPACE_PROJECT_ENVIRONMENT_READ_COPY = "WORKSPACE_PROJECT_ENVIRONMENT:READ+COPY"; + public static final String WORKSPACE_PROJECT_ENVIRONMENT_READ_IMPORT = "WORKSPACE_PROJECT_ENVIRONMENT:READ+IMPORT"; + public static final String WORKSPACE_PROJECT_ENVIRONMENT_READ_EXPORT = "WORKSPACE_PROJECT_ENVIRONMENT:READ+EXPORT"; public static final String PROJECT_USER_READ = "PROJECT_USER:READ"; diff --git a/backend/src/main/java/io/metersphere/service/UserService.java b/backend/src/main/java/io/metersphere/service/UserService.java index 5d0d0882bc..22ee85e89f 100644 --- a/backend/src/main/java/io/metersphere/service/UserService.java +++ b/backend/src/main/java/io/metersphere/service/UserService.java @@ -485,7 +485,7 @@ public class UserService { Workspace workspace = workspaceMapper.selectByPrimaryKey(sourceId); user.setLastOrganizationId(workspace.getOrganizationId()); user.setLastWorkspaceId(sourceId); - getProjectListByWsAndUserId(sourceId) + List projects = getProjectListByWsAndUserId(sourceId); if (projects.size() > 0) { user.setLastProjectId(projects.get(0).getId()); } else { diff --git a/backend/src/main/resources/db/migration/V86__v1.10_permission_refactor.sql b/backend/src/main/resources/db/migration/V85__v1.10_permission_refactor.sql similarity index 96% rename from backend/src/main/resources/db/migration/V86__v1.10_permission_refactor.sql rename to backend/src/main/resources/db/migration/V85__v1.10_permission_refactor.sql index de3d903983..c273e21abb 100644 --- a/backend/src/main/resources/db/migration/V86__v1.10_permission_refactor.sql +++ b/backend/src/main/resources/db/migration/V85__v1.10_permission_refactor.sql @@ -235,11 +235,26 @@ VALUES (uuid(), 'ws_admin', 'WORKSPACE_TEMPLATE:READ+CASE_TEMPLATE', 'WORKSPACE_ 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'); +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 metersphere_dev.user_group_permission (id, group_id, permission_id, module_id) +values (uuid(), 'ws_admin', 'WORKSPACE_PROJECT_ENVIRONMENT:READ','WORKSPACE_PROJECT_ENVIRONMENT'); +insert into metersphere_dev.user_group_permission (id, group_id, permission_id, module_id) +values (uuid(), 'ws_admin', 'WORKSPACE_PROJECT_ENVIRONMENT:READ+COPY','WORKSPACE_PROJECT_ENVIRONMENT'); +insert into metersphere_dev.user_group_permission (id, group_id, permission_id, module_id) +values (uuid(), 'ws_admin', 'WORKSPACE_PROJECT_ENVIRONMENT:READ+CREATE','WORKSPACE_PROJECT_ENVIRONMENT'); +insert into metersphere_dev.user_group_permission (id, group_id, permission_id, module_id) +values (uuid(), 'ws_admin', 'WORKSPACE_PROJECT_ENVIRONMENT:READ+IMPORT','WORKSPACE_PROJECT_ENVIRONMENT'); +insert into metersphere_dev.user_group_permission (id, group_id, permission_id, module_id) +values (uuid(), 'ws_admin', 'WORKSPACE_PROJECT_ENVIRONMENT:READ+EXPORT','WORKSPACE_PROJECT_ENVIRONMENT'); +insert into metersphere_dev.user_group_permission (id, group_id, permission_id, module_id) +values (uuid(), 'ws_admin', 'WORKSPACE_PROJECT_ENVIRONMENT:READ+EDIT','WORKSPACE_PROJECT_ENVIRONMENT'); +insert into metersphere_dev.user_group_permission (id, group_id, permission_id, module_id) +values (uuid(), 'ws_admin', 'WORKSPACE_PROJECT_ENVIRONMENT:READ+DELETE','WORKSPACE_PROJECT_ENVIRONMENT'); + -- 工作空间成员 INSERT INTO user_group_permission (id, group_id, permission_id, module_id) @@ -375,8 +390,6 @@ VALUES (uuid(), 'project_admin', 'PROJECT_API_REPORT:READ+DELETE', 'PROJECT_API_ INSERT INTO user_group_permission (id, group_id, permission_id, module_id) VALUES (uuid(), 'project_admin', 'PROJECT_PERFORMANCE_REPORT:READ', 'PROJECT_PERFORMANCE_REPORT'); INSERT INTO user_group_permission (id, group_id, permission_id, module_id) -VALUES (uuid(), 'project_admin', 'PROJECT_ENVIRONMENT:READ+DELETE', 'PROJECT_ENVIRONMENT'); -INSERT INTO user_group_permission (id, group_id, permission_id, module_id) VALUES (uuid(), 'project_admin', 'PROJECT_TRACK_CASE:READ+EDIT', 'PROJECT_TRACK_CASE'); INSERT INTO user_group_permission (id, group_id, permission_id, module_id) VALUES (uuid(), 'project_admin', 'PROJECT_API_DEFINITION:READ+CREATE_PERFORMANCE', 'PROJECT_API_DEFINITION'); @@ -387,8 +400,6 @@ VALUES (uuid(), 'project_admin', 'PROJECT_API_SCENARIO:READ+COPY', 'PROJECT_API_ INSERT INTO user_group_permission (id, group_id, permission_id, module_id) VALUES (uuid(), 'project_admin', 'PROJECT_API_DEFINITION:READ+RUN', 'PROJECT_API_DEFINITION'); INSERT INTO user_group_permission (id, group_id, permission_id, module_id) -VALUES (uuid(), 'project_admin', 'PROJECT_ENVIRONMENT:READ+CREATE', 'PROJECT_ENVIRONMENT'); -INSERT INTO user_group_permission (id, group_id, permission_id, module_id) VALUES (uuid(), 'project_admin', 'PROJECT_ENVIRONMENT:READ', 'PROJECT_ENVIRONMENT'); INSERT INTO user_group_permission (id, group_id, permission_id, module_id) VALUES (uuid(), 'project_admin', 'PROJECT_TRACK_CASE:READ+COPY', 'PROJECT_TRACK_CASE'); @@ -421,8 +432,6 @@ VALUES (uuid(), 'project_member', 'PROJECT_TRACK_REVIEW:READ+DELETE', 'PROJECT_T INSERT INTO user_group_permission (id, group_id, permission_id, module_id) VALUES (uuid(), 'project_member', 'PROJECT_API_SCENARIO:READ+IMPORT_SCENARIO', 'PROJECT_API_SCENARIO'); INSERT INTO user_group_permission (id, group_id, permission_id, module_id) -VALUES (uuid(), 'project_member', 'PROJECT_ENVIRONMENT:READ+DELETE', 'PROJECT_ENVIRONMENT'); -INSERT INTO user_group_permission (id, group_id, permission_id, module_id) VALUES (uuid(), 'project_member', 'PROJECT_TRACK_PLAN:READ+DELETE', 'PROJECT_TRACK_PLAN'); INSERT INTO user_group_permission (id, group_id, permission_id, module_id) VALUES (uuid(), 'project_member', 'PROJECT_TRACK_CASE:READ+DELETE', 'PROJECT_TRACK_CASE'); @@ -527,8 +536,6 @@ VALUES (uuid(), 'project_member', 'PROJECT_API_DEFINITION:READ+EDIT_CASE', 'PROJ INSERT INTO user_group_permission (id, group_id, permission_id, module_id) VALUES (uuid(), 'project_member', 'PROJECT_API_DEFINITION:READ', 'PROJECT_API_DEFINITION'); INSERT INTO user_group_permission (id, group_id, permission_id, module_id) -VALUES (uuid(), 'project_member', 'PROJECT_ENVIRONMENT:READ+CREATE', 'PROJECT_ENVIRONMENT'); -INSERT INTO user_group_permission (id, group_id, permission_id, module_id) VALUES (uuid(), 'project_member', 'PROJECT_API_SCENARIO:READ', 'PROJECT_API_SCENARIO'); INSERT INTO user_group_permission (id, group_id, permission_id, module_id) VALUES (uuid(), 'project_member', 'PROJECT_API_SCENARIO:READ+RUN', 'PROJECT_API_SCENARIO'); diff --git a/backend/src/main/resources/permission.json b/backend/src/main/resources/permission.json index dbd756dc0f..bfe9811cbe 100644 --- a/backend/src/main/resources/permission.json +++ b/backend/src/main/resources/permission.json @@ -277,7 +277,37 @@ { "id": "WORKSPACE_PROJECT_ENVIRONMENT:READ", "name": "查询环境", - "resourceId": "WORKSPACE_PROJECT_MANAGER" + "resourceId": "WORKSPACE_PROJECT_ENVIRONMENT" + }, + { + "id": "WORKSPACE_PROJECT_ENVIRONMENT:READ+CREATE", + "name": "创建环境", + "resourceId": "WORKSPACE_PROJECT_ENVIRONMENT" + }, + { + "id": "WORKSPACE_PROJECT_ENVIRONMENT:READ+EDIT", + "name": "编辑环境", + "resourceId": "WORKSPACE_PROJECT_ENVIRONMENT" + }, + { + "id": "WORKSPACE_PROJECT_ENVIRONMENT:READ+DELETE", + "name": "删除环境", + "resourceId": "WORKSPACE_PROJECT_ENVIRONMENT" + }, + { + "id": "WORKSPACE_PROJECT_ENVIRONMENT:READ+COPY", + "name": "复制环境", + "resourceId": "WORKSPACE_PROJECT_ENVIRONMENT" + }, + { + "id": "WORKSPACE_PROJECT_ENVIRONMENT:READ+IMPORT", + "name": "导入环境", + "resourceId": "WORKSPACE_PROJECT_ENVIRONMENT" + }, + { + "id": "WORKSPACE_PROJECT_ENVIRONMENT:READ+EXPORT", + "name": "导出环境", + "resourceId": "WORKSPACE_PROJECT_ENVIRONMENT" }, { "id": "WORKSPACE_TEMPLATE:READ", @@ -329,21 +359,21 @@ "name": "查询项目", "resourceId": "PROJECT_MANAGER" }, - { - "id": "PROJECT_MANAGER:READ+CREATE", - "name": "创建项目", - "resourceId": "PROJECT_MANAGER" - }, +// { +// "id": "PROJECT_MANAGER:READ+CREATE", +// "name": "创建项目", +// "resourceId": "PROJECT_MANAGER" +// }, { "id": "PROJECT_MANAGER:READ+EDIT", "name": "编辑项目", "resourceId": "PROJECT_MANAGER" }, - { - "id": "PROJECT_MANAGER:READ+DELETE", - "name": "删除项目", - "resourceId": "PROJECT_MANAGER" - }, +// { +// "id": "PROJECT_MANAGER:READ+DELETE", +// "name": "删除项目", +// "resourceId": "PROJECT_MANAGER" +// }, { "id": "PROJECT_ENVIRONMENT:READ", "name": "查询环境", diff --git a/frontend/src/business/components/common/components/MsTableOperator.vue b/frontend/src/business/components/common/components/MsTableOperator.vue index 786189e793..44d5acdf57 100644 --- a/frontend/src/business/components/common/components/MsTableOperator.vue +++ b/frontend/src/business/components/common/components/MsTableOperator.vue @@ -1,9 +1,9 @@ - -