| | |
| | | if (admin == null) { |
| | | throw new BusinessException("找不到管理员"); |
| | | } |
| | | if(!AdministratorEnums.ADMIN.getCode().equals(SecurityUtils.getUserDetails().getAdministratorType())){ |
| | | if (!AdministratorEnums.ADMIN.getCode().equals(SecurityUtils.getUserDetails().getAdministratorType())) { |
| | | throw new BusinessException("只有超级管理员才能删除用户"); |
| | | } |
| | | |
| | |
| | | //有用户必定有用户与角色的关系数据 |
| | | AdminRoleRelation one = adminRoleRelationService.getOne(Wrappers.lambdaQuery(AdminRoleRelation.class).eq(AdminRoleRelation::getAdminId, admin.getId())); |
| | | Role role = SpringContextHolder.getBean(RoleService.class).getOne(Wrappers.lambdaQuery(Role.class).eq(Role::getId, one.getRoleId())); |
| | | if (role == null) { |
| | | throw new BusinessException("数据异常!"); |
| | | } |
| | | |
| | | if (role.getLevel().equals(RoleLevelStatus.SUPER.getCode())) { |
| | | throw new BusinessException("超级管理员无法删除"); |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 删除管理员 日志记录开始 |
| | | */ |
| | | String content = "删除管理员:" + admin.getUsername() + "用户id:" + admin; |
| | | StoreOperationRecordsUtils.storeOperationData(null, null, "删除管理员", content); |
| | | /** |
| | | * 删除管理员 日志记录结束 |
| | | */ |
| | | |
| | | return flag; |
| | | } |
| | | |