From 1e5a94c05fcd43838c5d326d19868b7cc91d769b Mon Sep 17 00:00:00 2001 From: song-cc-rock Date: Mon, 4 Sep 2023 10:59:28 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E9=A1=B9=E7=9B=AE=E7=AE=A1=E7=90=86):=20?= =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=88=90=E5=91=98=E6=97=A5=E5=BF=97=E7=BC=BA?= =?UTF-8?q?=E5=B0=91=E6=93=8D=E4=BD=9C=E4=BA=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../metersphere/sdk/constants/PermissionConstants.java | 10 ++++++++++ .../project/controller/ProjectMemberController.java | 4 ++-- .../project/service/ProjectMemberService.java | 8 ++++---- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/backend/framework/sdk/src/main/java/io/metersphere/sdk/constants/PermissionConstants.java b/backend/framework/sdk/src/main/java/io/metersphere/sdk/constants/PermissionConstants.java index fb4df7f815..31813eddbe 100644 --- a/backend/framework/sdk/src/main/java/io/metersphere/sdk/constants/PermissionConstants.java +++ b/backend/framework/sdk/src/main/java/io/metersphere/sdk/constants/PermissionConstants.java @@ -97,6 +97,16 @@ public class PermissionConstants { public static final String PROJECT_MEMBER_DELETE = "PROJECT_MEMBER:READ+DELETE"; /*------ end: PROJECT_MEMBER ------*/ + /** + * 项目用户组 + */ + /*------ start: PROJECT_USER_ROLE ------*/ + public static final String PROJECT_USER_ROLE_READ = "PROJECT_USER_ROLE:READ"; + public static final String PROJECT_USER_ROLE_ADD = "PROJECT_USER_ROLE:READ+ADD"; + public static final String PROJECT_USER_ROLE_UPDATE = "PROJECT_USER_ROLE:READ+UPDATE"; + public static final String PROJECT_USER_ROLE_DELETE = "PROJECT_USER_ROLE:READ+DELETE"; + /*------ end: PROJECT_USER_ROLE ------*/ + public static final String SYSTEM_AUTH_READ = "SYSTEM_AUTH:READ"; public static final String SYSTEM_AUTH_READ_UPDATE = "SYSTEM_AUTH:READ+UPDATE"; diff --git a/backend/services/project-management/src/main/java/io/metersphere/project/controller/ProjectMemberController.java b/backend/services/project-management/src/main/java/io/metersphere/project/controller/ProjectMemberController.java index 1c19b1f13c..388d4ffd89 100644 --- a/backend/services/project-management/src/main/java/io/metersphere/project/controller/ProjectMemberController.java +++ b/backend/services/project-management/src/main/java/io/metersphere/project/controller/ProjectMemberController.java @@ -83,7 +83,7 @@ public class ProjectMemberController { }) @RequiresPermissions(PermissionConstants.PROJECT_MEMBER_DELETE) public void removeMember(@PathVariable String projectId, @PathVariable String userId) { - projectMemberService.removeMember(projectId, userId); + projectMemberService.removeMember(projectId, userId, SessionUtils.getUserId()); } @PostMapping("/add-role") @@ -97,6 +97,6 @@ public class ProjectMemberController { @Operation(summary = "项目管理-成员-批量从项目移除") @RequiresPermissions(PermissionConstants.PROJECT_MEMBER_DELETE) public void batchRemove(@RequestBody ProjectMemberBatchDeleteRequest request) { - projectMemberService.batchRemove(request); + projectMemberService.batchRemove(request, SessionUtils.getUserId()); } } diff --git a/backend/services/project-management/src/main/java/io/metersphere/project/service/ProjectMemberService.java b/backend/services/project-management/src/main/java/io/metersphere/project/service/ProjectMemberService.java index 23d671def4..752d4152cf 100644 --- a/backend/services/project-management/src/main/java/io/metersphere/project/service/ProjectMemberService.java +++ b/backend/services/project-management/src/main/java/io/metersphere/project/service/ProjectMemberService.java @@ -218,7 +218,7 @@ public class ProjectMemberService { * @param projectId 项目ID * @param userId 用户ID */ - public void removeMember(String projectId, String userId) { + public void removeMember(String projectId, String userId, String currentUserId) { // 操作记录 List logs = new ArrayList<>(); // 项目不存在, 则不移除 @@ -228,7 +228,7 @@ public class ProjectMemberService { example.createCriteria().andSourceIdEqualTo(projectId).andUserIdEqualTo(userId); userRoleRelationMapper.deleteByExample(example); // 操作记录 - setLog(projectId, userId, null, OperationLogType.DELETE.name(), "/project/member/remove", HttpMethodConstants.GET.name(), null, null, logs); + setLog(projectId, userId, currentUserId, OperationLogType.DELETE.name(), "/project/member/remove", HttpMethodConstants.GET.name(), null, null, logs); operationLogService.batchAdd(logs); } @@ -309,7 +309,7 @@ public class ProjectMemberService { * 批量移除成员(项目) * @param request 请求参数 */ - public void batchRemove(ProjectMemberBatchDeleteRequest request) { + public void batchRemove(ProjectMemberBatchDeleteRequest request, String currentUserId) { // 操作记录 List logs = new ArrayList<>(); // 项目不存在, 则不移除 @@ -322,7 +322,7 @@ public class ProjectMemberService { // 操作记录 request.getUserIds().forEach(userId -> { // 操作记录 - setLog(request.getProjectId(), userId, null, OperationLogType.DELETE.name(), "/project/member/remove", HttpMethodConstants.GET.name(), null, null, logs); + setLog(request.getProjectId(), userId, currentUserId, OperationLogType.DELETE.name(), "/project/member/remove", HttpMethodConstants.GET.name(), null, null, logs); }); operationLogService.batchAdd(logs); }