| | |
| | | throw new RuntimeException("该部门不存在"); |
| | | } |
| | | if (Objects.nonNull(department.getAdminId())) { |
| | | Integer adminNum = departmentMapper.countByAdminId(department.getAdminId(), department.getId()); |
| | | if (adminNum > 0) { |
| | | throw new RuntimeException("一个用户只能是一个单位的管理员"); |
| | | } |
| | | if (! Objects.equals(entity.getAdminId(), department.getAdminId())) { |
| | | // 取消原先的管理员标识 |
| | | List<Integer> depIds = departmentMapper.selectByAdminId(entity.getAdminId()); |
| | | depIds.remove(department.getId()); |
| | | if (depIds.size() < 1) { |
| | | userMapper.updateDeptAdmin(entity.getAdminId(), DeptAdminEnum.NO.getValue()); |
| | | } |
| | | userMapper.updateDeptAdmin(entity.getAdminId(), DeptAdminEnum.NO.getValue()); |
| | | } |
| | | // 标识部门管理员 |
| | | userMapper.updateDeptAdmin(department.getAdminId(), DeptAdminEnum.YES.getValue()); |
| | |
| | | } |
| | | |
| | | @Override |
| | | public List<Department> gets() { |
| | | return departmentMapper.gets(); |
| | | public List<Department> gets(Integer deptId) { |
| | | if (deptId == null || deptId == -1) { |
| | | deptId = null; |
| | | } |
| | | return departmentMapper.gets(deptId); |
| | | } |
| | | |
| | | @Override |
| | |
| | | throw new RuntimeException("该部门不存在"); |
| | | } |
| | | if (Objects.nonNull(form.getAdminId())) { |
| | | Integer adminNum = departmentMapper.countByAdminId(form.getAdminId(), form.getId()); |
| | | if (adminNum > 0) { |
| | | throw new RuntimeException("一个用户只能是一个单位的管理员"); |
| | | } |
| | | if (! Objects.equals(entity.getAdminId(), form.getAdminId())) { |
| | | // 取消原先的管理员标识 |
| | | List<Integer> depIds = departmentMapper.selectByAdminId(entity.getAdminId()); |
| | | depIds.remove(form.getId()); |
| | | if (depIds.size() < 1) { |
| | | userMapper.updateDeptAdmin(entity.getAdminId(), DeptAdminEnum.NO.getValue()); |
| | | } |
| | | userMapper.updateDeptAdmin(entity.getAdminId(), DeptAdminEnum.NO.getValue()); |
| | | } |
| | | // 标识部门管理员 |
| | | userMapper.updateDeptAdmin(form.getAdminId(), DeptAdminEnum.YES.getValue()); |