@Test public void removePermissions() { GroupDO group = GroupDO.builder().name("测试分组1").info("just for test").build(); PermissionDO permission1 = PermissionDO.builder().name("权限1").module("炉石传说").build(); PermissionDO permission2 = PermissionDO.builder().name("权限2").module("炉石传说").build(); PermissionDO permission3 = PermissionDO.builder().name("权限3").module("炉石传说").build(); groupMapper.insert(group); permissionMapper.insert(permission1); permissionMapper.insert(permission2); permissionMapper.insert(permission3); List<GroupPermissionDO> relations = new ArrayList<>(); GroupPermissionDO relation1 = new GroupPermissionDO(group.getId(), permission1.getId()); GroupPermissionDO relation2 = new GroupPermissionDO(group.getId(), permission2.getId()); GroupPermissionDO relation3 = new GroupPermissionDO(group.getId(), permission3.getId()); relations.add(relation1); relations.add(relation2); relations.add(relation3); groupPermissionMapper.insertBatch(relations); RemovePermissionsDTO dto = new RemovePermissionsDTO(); dto.setGroupId(group.getId()); dto.setPermissionIds(Arrays.asList(permission3.getId(), permission2.getId())); boolean ok = adminService.removePermissions(dto); assertTrue(ok); GroupPermissionsBO groupPermissions = adminService.getGroup(group.getId()); boolean anyMatch = groupPermissions.getPermissions().stream().anyMatch(it -> { PermissionDO p = (PermissionDO) it; return p.getName().equals("权限3") && p.getModule().equals("炉石传说"); }); assertFalse(anyMatch); anyMatch = groupPermissions.getPermissions().stream().anyMatch(it -> { PermissionDO p = (PermissionDO) it; return p.getName().equals("权限1") && p.getModule().equals("炉石传说"); }); assertTrue(anyMatch); }
@Override public boolean removePermissions(RemovePermissionsDTO dto) { return groupPermissionMapper.deleteBatchByGroupIdAndPermissionId(dto.getGroupId(), dto.getPermissionIds()) > 0; }
AdminServiceImpl implements AdminService { @Override public boolean removePermissions(RemovePermissionsDTO dto) { return groupPermissionMapper.deleteBatchByGroupIdAndPermissionId(dto.getGroupId(), dto.getPermissionIds()) > 0; } }
AdminServiceImpl implements AdminService { @Override public boolean removePermissions(RemovePermissionsDTO dto) { return groupPermissionMapper.deleteBatchByGroupIdAndPermissionId(dto.getGroupId(), dto.getPermissionIds()) > 0; }  }
AdminServiceImpl implements AdminService { @Override public boolean removePermissions(RemovePermissionsDTO dto) { return groupPermissionMapper.deleteBatchByGroupIdAndPermissionId(dto.getGroupId(), dto.getPermissionIds()) > 0; }  @Override IPage<UserDO> getUserPageByGroupId(Long groupId, Long count, Long page); @Override boolean changeUserPassword(Long id, ResetPasswordDTO dto); @Transactional @Override boolean deleteUser(Long id); @Override boolean updateUserInfo(Long id, UpdateUserInfoDTO validator); @Override IPage<GroupDO> getGroupPage(Long page, Long count); @Override GroupPermissionsBO getGroup(Long id); @Transactional @Override boolean createGroup(NewGroupDTO dto); @Override boolean updateGroup(Long id, UpdateGroupDTO dto); @Override boolean deleteGroup(Long id); @Override boolean dispatchPermission(DispatchPermissionDTO dto); @Override boolean dispatchPermissions(DispatchPermissionsDTO dto); @Override boolean removePermissions(RemovePermissionsDTO dto); @Override List<GroupDO> getAllGroups(); @Override List<PermissionDO> getAllPermissions(); @Override Map<String, List<PermissionDO>> getAllStructualPermissions(); }
AdminServiceImpl implements AdminService { @Override public boolean removePermissions(RemovePermissionsDTO dto) { return groupPermissionMapper.deleteBatchByGroupIdAndPermissionId(dto.getGroupId(), dto.getPermissionIds()) > 0; }  @Override IPage<UserDO> getUserPageByGroupId(Long groupId, Long count, Long page); @Override boolean changeUserPassword(Long id, ResetPasswordDTO dto); @Transactional @Override boolean deleteUser(Long id); @Override boolean updateUserInfo(Long id, UpdateUserInfoDTO validator); @Override IPage<GroupDO> getGroupPage(Long page, Long count); @Override GroupPermissionsBO getGroup(Long id); @Transactional @Override boolean createGroup(NewGroupDTO dto); @Override boolean updateGroup(Long id, UpdateGroupDTO dto); @Override boolean deleteGroup(Long id); @Override boolean dispatchPermission(DispatchPermissionDTO dto); @Override boolean dispatchPermissions(DispatchPermissionsDTO dto); @Override boolean removePermissions(RemovePermissionsDTO dto); @Override List<GroupDO> getAllGroups(); @Override List<PermissionDO> getAllPermissions(); @Override Map<String, List<PermissionDO>> getAllStructualPermissions();  }