| | |
| | | /** |
| | | * 限制管理员只有一个 |
| | | */ |
| | | if (sysDoctor.getRoles().contains(CommonConstant.HOSPITAL_ADMIN_ID)) { |
| | | //查询一个部门下的所有医生 |
| | | QueryWrapper wrapper = new QueryWrapper(); |
| | | wrapper.eq("is_del", 0); |
| | | wrapper.eq("enabled", 1); |
| | | wrapper.eq("department_id", sysDoctor.getDepartmentId()); |
| | | List<SysDoctor> doctoerList = this.baseMapper.selectList(wrapper); |
| | | if (doctoerList.size() > 0) { |
| | | //查询role——user |
| | | List<Long> collect = doctoerList.stream().map(e -> e.getUserId()).collect(Collectors.toList()); |
| | | wrapper = new QueryWrapper(); |
| | | wrapper.in("user_id", collect); |
| | | List<SysRoleUser> list = this.sysUserRoleMapper.selectList(wrapper); |
| | | for (SysRoleUser sysRoleUser : list) { |
| | | if (sysRoleUser.getRoleId().equals(CommonConstant.HOSPITAL_ADMIN_ID)) { |
| | | flag = true; |
| | | if (sysDoctor.getDoctorType() != 2) { |
| | | if (sysDoctor.getRoles().contains(CommonConstant.HOSPITAL_ADMIN_ID)) { |
| | | //查询一个部门下的所有医生 |
| | | QueryWrapper wrapper = new QueryWrapper(); |
| | | wrapper.eq("is_del", 0); |
| | | wrapper.eq("enabled", 1); |
| | | wrapper.eq("department_id", sysDoctor.getDepartmentId()); |
| | | List<SysDoctor> doctoerList = this.baseMapper.selectList(wrapper); |
| | | if (doctoerList.size() > 0) { |
| | | //查询role——user |
| | | List<Long> collect = doctoerList.stream().map(e -> e.getUserId()).collect(Collectors.toList()); |
| | | wrapper = new QueryWrapper(); |
| | | wrapper.in("user_id", collect); |
| | | List<SysRoleUser> list = this.sysUserRoleMapper.selectList(wrapper); |
| | | for (SysRoleUser sysRoleUser : list) { |
| | | if (sysRoleUser.getRoleId().equals(CommonConstant.HOSPITAL_ADMIN_ID)) { |
| | | flag = true; |
| | | } |
| | | } |
| | | } |
| | | } |
| | |
| | | sysRoleUser.setRoleId(CommonConstant.HOSPITAL_DOCTOR_ID); |
| | | QueryWrapper queryWrapper = new QueryWrapper(); |
| | | queryWrapper.eq("user_id", adminId); |
| | | queryWrapper.eq("role_id", CommonConstant.HOSPITAL_ADMIN_ID); |
| | | int update = sysUserRoleMapper.update(sysRoleUser, queryWrapper); |
| | | // queryWrapper.eq("role_id", CommonConstant.HOSPITAL_ADMIN_ID); |
| | | int delete = sysUserRoleMapper.delete(queryWrapper); |
| | | int update = sysUserRoleMapper.insert(sysRoleUser); |
| | | //现将操作人员设为非管理角色 |
| | | sysDoctor.setIsAdminUser(false); |
| | | if (baseMapper.updateById(sysDoctor) > 0) { |
| | |
| | | sysRoleUser.setRoleId(CommonConstant.HOSPITAL_ADMIN_ID); |
| | | queryWrapper = new QueryWrapper(); |
| | | queryWrapper.eq("user_id", sysDoctor.getUserId()); |
| | | queryWrapper.eq("role_id", CommonConstant.HOSPITAL_DOCTOR_ID); |
| | | sysUserRoleMapper.update(sysRoleUser, queryWrapper); |
| | | // queryWrapper.eq("role_id", CommonConstant.HOSPITAL_DOCTOR_ID); |
| | | sysUserRoleMapper.delete(queryWrapper); |
| | | sysUserRoleMapper.insert(sysRoleUser); |
| | | sysDoctor.setIsAdminUser(true); |
| | | if (baseMapper.updateById(sysDoctor) > 0) { |
| | | return ResultBody.ok().data(true).msg("管理员设置成功!"); |