public void saveRoleCategories(String roleId, String[] categoryIds) {
        roleCategoryRepository.deleteByRoleId(roleId);
        if (ArrayUtils.isNotEmpty(categoryIds)) {
            roleCategoryRepository.saveAll(Arrays.stream(categoryIds)
                    .map(categoryId -> new RoleCategory()
                            .setId(StringExtUtils.getUuid())
                            .setCategoryId(categoryId)
                            .setRoleId(roleId))
                    .collect(Collectors.toList()));
        }
        cacheService.getCategoryRolesCache().invalidateAll(Arrays.stream(categoryIds)
                .collect(Collectors.toSet()));
    }
saveRoleCategories

@param roleId roleId
@param categoryIds categoryIds
src/main/java/com/tuituidan/openhub/service/RoleService.java