| | |
| | | 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; |
| | | } |
| | |
| | | */ |
| | | public List<MenuNode> getUserPermissionList() { |
| | | List<MenuNode> resultList; |
| | | //判断超管与普通管理员 |
| | | if (SecurityUtils.getAdministratorIdentity().equals(AdministratorEnums.ADMIN.getCode())) { |
| | | //参数为null时,获取所有的菜单权限 |
| | | resultList = SpringContextHolder.getBean(MenuService.class).getUserPermissionListById(null); |
| | | } else { |
| | | //通过用户UserID获取用户角色 |
| | | AdminRoleRelation one = SpringContextHolder.getBean(AdminRoleRelationService.class). |
| | | getOne(Wrappers.lambdaQuery(AdminRoleRelation.class).eq(AdminRoleRelation::getAdminId, SecurityUtils.getUserId())); |
| | | //判空 |
| | | if (one == null) { |
| | | throw new BusinessException("该用户未绑定角色"); |
| | | } |
| | | |
| | | //通过RoleID获取MeunId列表 |
| | | List<RoleMenuRelation> menuIdList = SpringContextHolder.getBean(RoleMenuRelationService.class) |
| | | .list(Wrappers.lambdaQuery(RoleMenuRelation.class).eq(RoleMenuRelation::getRoleId, one.getRoleId())); |
| | | |
| | | //判空 |
| | | if (menuIdList.isEmpty()) { |
| | | return new ArrayList<>(); |
| | | } |
| | | List<Long> menuIds = new ArrayList<>(menuIdList.size()); |
| | | for (RoleMenuRelation bean : menuIdList) { |
| | | menuIds.add(bean.getMenuId()); |
| | | } |
| | | |
| | | resultList = SpringContextHolder.getBean(MenuService.class).getUserPermissionListById(menuIds); |
| | | |
| | | //通过用户UserID获取用户角色 |
| | | AdminRoleRelation one = SpringContextHolder.getBean(AdminRoleRelationService.class). |
| | | getOne(Wrappers.lambdaQuery(AdminRoleRelation.class).eq(AdminRoleRelation::getAdminId, SecurityUtils.getUserId())); |
| | | //判空 |
| | | if (one == null) { |
| | | throw new BusinessException("该用户未绑定角色"); |
| | | } |
| | | |
| | | //通过RoleID获取MeunId列表 |
| | | List<RoleMenuRelation> menuIdList = SpringContextHolder.getBean(RoleMenuRelationService.class) |
| | | .list(Wrappers.lambdaQuery(RoleMenuRelation.class).eq(RoleMenuRelation::getRoleId, one.getRoleId())); |
| | | |
| | | //判空 |
| | | if (menuIdList.isEmpty()) { |
| | | return new ArrayList<>(); |
| | | } |
| | | List<Long> menuIds = new ArrayList<>(menuIdList.size()); |
| | | for (RoleMenuRelation bean : menuIdList) { |
| | | menuIds.add(bean.getMenuId()); |
| | | } |
| | | |
| | | resultList = SpringContextHolder.getBean(MenuService.class).getUserPermissionListById(menuIds); |
| | | |
| | | return resultList; |
| | | } |
| | | } |