diff --git a/src/main/java/com/huoran/iasf/service/impl/UserServiceImpl.java b/src/main/java/com/huoran/iasf/service/impl/UserServiceImpl.java index 5693037..36fd477 100644 --- a/src/main/java/com/huoran/iasf/service/impl/UserServiceImpl.java +++ b/src/main/java/com/huoran/iasf/service/impl/UserServiceImpl.java @@ -197,10 +197,11 @@ public class UserServiceImpl extends ServiceImpl impleme vo.setEmail(vo.getPhone()); } - //删除所有部门 - userDeptMapper.delete(Wrappers.lambdaQuery().eq(UserDept::getUserId, vo.getId())); //更新部门 if (!CollectionUtils.isEmpty(vo.getDeptArchitectureId())) { + //删除所有部门 + userDeptMapper.delete(Wrappers.lambdaQuery().eq(UserDept::getUserId, vo.getId())); + List deptArchitectureId = vo.getDeptArchitectureId(); for (Integer deptId : deptArchitectureId) { UserDept userDept = new UserDept(); @@ -210,10 +211,12 @@ public class UserServiceImpl extends ServiceImpl impleme } } - LambdaQueryWrapper queryWrapper = Wrappers.lambdaQuery(); - queryWrapper.eq(SysUserRole::getUserId, vo.getId()); - userRoleService.remove(queryWrapper); + if (!CollectionUtils.isEmpty(vo.getRoleIds())) { + LambdaQueryWrapper queryWrapper = Wrappers.lambdaQuery(); + queryWrapper.eq(SysUserRole::getUserId, vo.getId()); + userRoleService.remove(queryWrapper); + UserRoleOperationReqVO reqVO = new UserRoleOperationReqVO(); reqVO.setUserId(vo.getId()); reqVO.setRoleIds(vo.getRoleIds());