From c14a8b24c3a38f11047a5be31a972e1dba2e1ea0 Mon Sep 17 00:00:00 2001 From: shiziyuan9527 Date: Mon, 8 Jun 2020 16:08:53 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A7=BB=E9=99=A4=E8=A7=92=E8=89=B2=E6=97=B6?= =?UTF-8?q?=E5=88=A4=E6=96=AD=E6=98=AF=E5=90=A6=E9=9C=80=E8=A6=81=E6=B8=85?= =?UTF-8?q?=E7=A9=BAlastWsId=E5=92=8ClastOrgId?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../io/metersphere/service/UserService.java | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/backend/src/main/java/io/metersphere/service/UserService.java b/backend/src/main/java/io/metersphere/service/UserService.java index 00388570b0..2c8815b1db 100644 --- a/backend/src/main/java/io/metersphere/service/UserService.java +++ b/backend/src/main/java/io/metersphere/service/UserService.java @@ -195,6 +195,17 @@ public class UserService { String userId = user.getId(); UserRoleExample userRoleExample = new UserRoleExample(); userRoleExample.createCriteria().andUserIdEqualTo(userId); + List userRoles = userRoleMapper.selectByExample(userRoleExample); + List list = userRoles.stream().map(UserRole::getSourceId).collect(Collectors.toList()); + + if (!CollectionUtils.isEmpty(list)) { + if (list.contains(user.getLastWorkspaceId()) || list.contains(user.getLastOrganizationId())) { + user.setLastOrganizationId(""); + user.setLastWorkspaceId(""); + userMapper.updateByPrimaryKeySelective(user); + } + } + userRoleMapper.deleteByExample(userRoleExample); List> roles = user.getRoles(); if (!roles.isEmpty()) { @@ -275,6 +286,14 @@ public class UserService { UserRoleExample example = new UserRoleExample(); example.createCriteria().andRoleIdLike("%test%") .andUserIdEqualTo(userId).andSourceIdEqualTo(workspaceId); + + User user = userMapper.selectByPrimaryKey(userId); + if (StringUtils.equals(workspaceId, user.getLastWorkspaceId())) { + user.setLastWorkspaceId(""); + user.setLastOrganizationId(""); + userMapper.updateByPrimaryKeySelective(user); + } + userRoleMapper.deleteByExample(example); } @@ -305,6 +324,14 @@ public class UserService { public void delOrganizationMember(String organizationId, String userId) { UserRoleExample userRoleExample = new UserRoleExample(); userRoleExample.createCriteria().andRoleIdLike("%org%").andUserIdEqualTo(userId).andSourceIdEqualTo(organizationId); + + User user = userMapper.selectByPrimaryKey(userId); + if (StringUtils.equals(organizationId, user.getLastOrganizationId())) { + user.setLastWorkspaceId(""); + user.setLastOrganizationId(""); + userMapper.updateByPrimaryKeySelective(user); + } + userRoleMapper.deleteByExample(userRoleExample); }