|
@@ -542,8 +542,29 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
|
|
UserBatchDisposeResult userBatchDisposeResult = this.disposeUserInfoHelp(userSaveParamsList, sysUser);
|
|
|
List<SysUser> sysUserList = userBatchDisposeResult.getUserList();
|
|
|
List<SysUserRole> sysUserRoleList = userBatchDisposeResult.getUserRoleList();
|
|
|
+ Set<Long> removeUserIdSet = userBatchDisposeResult.getRemoveIdSet();
|
|
|
+ Set<Long> updateUserIdSet = userBatchDisposeResult.getUpdateIdSet();
|
|
|
+ // TODO: 2021/9/1 可以优化 或者直接批量导入变成单个导入 循环调用
|
|
|
+ // 保存用户
|
|
|
this.saveOrUpdateBatch(sysUserList);
|
|
|
+ // 要更新的用户删除原先的权限
|
|
|
+ for (Long id : removeUserIdSet) {
|
|
|
+ QueryWrapper<SysUserRole> sysUserRoleQueryWrapper = new QueryWrapper<>();
|
|
|
+ sysUserRoleQueryWrapper.lambda().eq(SysUserRole::getUserId, id);
|
|
|
+ sysUserRoleService.remove(sysUserRoleQueryWrapper);
|
|
|
+ commonCacheService.removeUserRolePrivilegeCache(id);
|
|
|
+ }
|
|
|
+ // 更新用户角色权限
|
|
|
sysUserRoleService.saveOrUpdateBatch(sysUserRoleList);
|
|
|
+ // 要更新的角色删除缓存
|
|
|
+ for (Long id : removeUserIdSet) {
|
|
|
+ commonService.removeUserInfo(id, true);
|
|
|
+ }
|
|
|
+ // 基础数据变更更新缓存
|
|
|
+ for (Long id : updateUserIdSet) {
|
|
|
+ commonCacheService.updateUserCache(id);
|
|
|
+ commonCacheService.updateUserAuthCache(id);
|
|
|
+ }
|
|
|
return map;
|
|
|
}
|
|
|
|
|
@@ -644,6 +665,10 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
|
|
Long schoolId = master.getSchoolId();
|
|
|
List<SysUser> userList = new ArrayList<>();
|
|
|
List<SysUserRole> sysUserRoleList = new ArrayList<>();
|
|
|
+ // 用户角色更新 - 对用户角色权限的各种清除操作
|
|
|
+ Set<Long> willRemoveUserPri = new HashSet<>();
|
|
|
+ // 用户基础信息更新 - 对用户权限缓存的更新
|
|
|
+ Set<Long> willUpdateUserPri = new HashSet<>();
|
|
|
for (UserSaveParams userSaveParams : userSaveParamsList) {
|
|
|
String code = userSaveParams.getCode();
|
|
|
String mobileNumber = userSaveParams.getMobileNumber();
|
|
@@ -681,21 +706,15 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
|
|
userList.add(userCell);
|
|
|
//如果修改了角色,需要重新登录
|
|
|
if (count == 0 || dbUserRolesList.size() != newRoleList.size()) {
|
|
|
- QueryWrapper<SysUserRole> sysUserRoleQueryWrapper = new QueryWrapper<>();
|
|
|
- sysUserRoleQueryWrapper.lambda().eq(SysUserRole::getUserId, userCell.getId());
|
|
|
- sysUserRoleService.remove(sysUserRoleQueryWrapper);
|
|
|
-
|
|
|
- commonCacheService.removeUserRolePrivilegeCache(userCell.getId());
|
|
|
List<SysUserRole> sysUserRoleCell = commonService.disposeUserPrivilege(userCell, userSaveParams.getRoleIds());
|
|
|
sysUserRoleList.addAll(sysUserRoleCell);
|
|
|
- commonService.removeUserInfo(userCell.getId(), true);
|
|
|
+ willRemoveUserPri.add(userCell.getId());
|
|
|
}
|
|
|
//如果修改了机构或手机号,需更新用户缓存
|
|
|
if (Objects.nonNull(dbUser.getOrgId())) {
|
|
|
if (dbUser.getOrgId().longValue() != userCell.getOrgId().longValue()
|
|
|
|| !Objects.equals(dbUser.getMobileNumber(), userCell.getMobileNumber())) {
|
|
|
- commonCacheService.updateUserCache(userCell.getId());
|
|
|
- commonCacheService.updateUserAuthCache(userCell.getId());
|
|
|
+ willUpdateUserPri.add(userCell.getId());
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -703,6 +722,10 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
|
|
UserBatchDisposeResult userBatchDisposeResult = new UserBatchDisposeResult();
|
|
|
userBatchDisposeResult.setUserList(userList);
|
|
|
userBatchDisposeResult.setUserRoleList(sysUserRoleList);
|
|
|
+ userBatchDisposeResult.setRemoveIdSet(willRemoveUserPri);
|
|
|
+
|
|
|
+ userBatchDisposeResult.setUpdateIdSet(willUpdateUserPri);
|
|
|
+
|
|
|
return userBatchDisposeResult;
|
|
|
}
|
|
|
|