| | |
| | | if (Objects.isNull(entity)) { |
| | | throw new RuntimeException("该部门不存在"); |
| | | } |
| | | // 先清除之前的管理员标识 |
| | | List<BaseSelect> deptUserList = userDepartmentMapper.getDeptUserList(entity.getId()); |
| | | List<Integer> userIds = deptUserList.stream().map(BaseSelect::getId).collect(Collectors.toList()); |
| | | if (! CollectionUtils.isEmpty(userIds)) { |
| | | userMapper.clearDeptAdmin(userIds, entity.getId()); |
| | | userMapper.cancelUserDeptAdmin(userIds); |
| | | } |
| | | // 设置部门管理员 |
| | | if (! CollectionUtils.isEmpty(department.getAdminId())) { |
| | | List<BaseSelect> deptUserList = userDepartmentMapper.getDeptUserList(entity.getId()); |
| | | List<Integer> userIds = deptUserList.stream().map(BaseSelect::getId).collect(Collectors.toList()); |
| | | if (! CollectionUtils.isEmpty(userIds)) { |
| | | // 先清除之前的管理员标识 |
| | | userMapper.clearDeptAdmin(userIds, entity.getId()); |
| | | } |
| | | // 标识部门管理员 |
| | | userMapper.updateDeptAdmin(department.getAdminId(), DeptAdminEnum.YES.getValue(), entity.getId()); |
| | | UpdateDeptAdminVO updateDeptAdminVO = new UpdateDeptAdminVO(); |
| | | updateDeptAdminVO.setAdminIds(department.getAdminId()); |
| | | userMapper.updateUserDeptAdmin(updateDeptAdminVO); |
| | | } |
| | | if (Objects.nonNull(department.getParentId())) { |
| | | // 查出父级的层级 |
| | |
| | | Collections.reverse(fatherList); |
| | | vo.setParentIds(fatherList); |
| | | } |
| | | vo.setAdminId(userDepartmentMapper.selectDeptAdmin(id)); |
| | | return vo; |
| | | } |
| | | |
| | |
| | | if (Objects.isNull(entity)) { |
| | | throw new RuntimeException("该部门不存在"); |
| | | } |
| | | List<BaseSelect> deptUserList = userDepartmentMapper.getDeptUserList(entity.getId()); |
| | | List<Integer> userIds = deptUserList.stream().map(BaseSelect::getId).collect(Collectors.toList()); |
| | | if (! CollectionUtils.isEmpty(userIds)) { |
| | | // 先清除之前的管理员标识 |
| | | userMapper.clearDeptAdmin(userIds, entity.getId()); |
| | | // 修改没被选择的用户并且不是别的部门管理员的用户角色为1 |
| | | userMapper.cancelUserDeptAdmin(userIds); |
| | | } |
| | | if (! CollectionUtils.isEmpty(form.getAdminIds())) { |
| | | List<BaseSelect> deptUserList = userDepartmentMapper.getDeptUserList(entity.getId()); |
| | | List<Integer> userIds = deptUserList.stream().map(BaseSelect::getId).collect(Collectors.toList()); |
| | | if (! CollectionUtils.isEmpty(userIds)) { |
| | | // 先清除之前的管理员标识 |
| | | userMapper.clearDeptAdmin(userIds, entity.getId()); |
| | | } |
| | | // 标识部门管理员 |
| | | userMapper.updateDeptAdmin(form.getAdminIds(), DeptAdminEnum.YES.getValue(), entity.getId()); |
| | | // 修改被选择的用户为部门管理员 |
| | | userMapper.updateUserDeptAdmin(form); |
| | | } |
| | | // 修改被选择的用户为部门管理员 |
| | | userMapper.updateUserDeptAdmin(form); |
| | | // 修改没被选择的用户并且不是别的部门管理员的用户角色为1 |
| | | userMapper.cancelUserDeptAdmin(form); |
| | | } |
| | | |
| | | @Override |