class DefaultMenuService
    extends GenericReactiveCrudService<MenuEntity, String>
    implements ReactiveTreeSortEntityService<MenuEntity, String> {

    private final ReactiveRepository<MenuBindEntity, String> bindRepository;

    private final ApplicationEventPublisher eventPublisher;

    public DefaultMenuService(ReactiveRepository<MenuBindEntity, String> bindRepository,
                              ApplicationEventPublisher eventPublisher) {
        this.bindRepository = bindRepository;
        this.eventPublisher = eventPublisher;
    }

    @Override
    @Generated
    public IDGenerator<String> getIDGenerator() {
        return IDGenerator.MD5;
    }

    @Override
    @Generated
    public void setChildren(MenuEntity menuEntity, List<MenuEntity> children) {
        menuEntity.setChildren(children);
    }

    @Override
    @Generated
    public List<MenuEntity> getChildren(MenuEntity menuEntity) {
        return menuEntity.getChildren();
    }

    public Flux<MenuView> getMenuViews(QueryParamEntity queryParam, Predicate<MenuEntity> menuPredicate) {
        return this
            .createQuery()
            .setParam(queryParam.noPaging())
            .orderBy(SortOrder.asc(MenuEntity::getSortIndex))
            .fetch()
            .collectMap(MenuEntity::getId, Function.identity())
            .flatMapIterable(menus -> convertMenuView(menus, menuPredicate, MenuView::of));
    }

    /**
     * 根据维度获取已经授权的菜单信息
     *
     * @param dimensions 维度信息
     * @return 菜单信息
     */
    public Flux<MenuView> getGrantedMenus(QueryParamEntity queryParam, List<Dimension> dimensions) {<FILL_FUNCTION_BODY>}

    public Flux<MenuView> getGrantedMenus(String dimensionType, String dimensionId) {
        return getGrantedMenus(dimensionType, Collections.singleton(dimensionId));
    }

    public Flux<MenuView> getGrantedMenus(String dimensionType, Collection<String> dimensionIds) {
        return bindRepository
            .createQuery()
            .where()
            .in(MenuBindEntity::getTargetKey, dimensionIds
                .stream()
                .map(dimensionId -> MenuBindEntity.generateTargetKey(dimensionType, dimensionId))
                .collect(Collectors.toSet()))
            .fetch()
            .as(this::convertToView);
    }


    private Flux<MenuView> convertToView(Flux<MenuBindEntity> entityFlux) {
        return Mono
            .zip(
                //全部菜单数据
                this
                    .createQuery()
                    .where()
                    .and(MenuEntity::getStatus, 1)
                    .fetch()
                    .collectMap(MenuEntity::getId, Function.identity(), LinkedHashMap::new),
                //菜单绑定信息
                entityFlux.collect(Collectors.groupingBy(MenuBindEntity::getMenuId)),
                (menus, binds) -> convertMenuView(menus,
                                                  menu -> binds.get(menu.getId()) != null,
                                                  menu -> MenuView.of(menu, binds.get(menu.getId())))
            )
            .flatMapIterable(Function.identity());
    }

    public Collection<MenuView> convertMenuView(Map<String, MenuEntity> menuMap,
                                                Predicate<MenuEntity> menuPredicate,
                                                Function<MenuEntity, MenuView> converter) {
        Map<String, MenuEntity> group = new HashMap<>();
        for (MenuEntity menu : menuMap.values()) {
            if (group.containsKey(menu.getId())) {
                continue;
            }
            if (menuPredicate.test(menu)) {
                String parentId = menu.getParentId();
                MenuEntity parent;
                group.put(menu.getId(), menu);
                //有子菜单默认就有父菜单
                while (StringUtils.hasText(parentId)) {
                    parent = menuMap.get(parentId);
                    if (parent == null) {
                        break;
                    }
                    parentId = parent.getParentId();
                    group.put(parent.getId(), parent);
                }
            }
        }
        return group
            .values()
            .stream()
            .map(converter)
            .sorted()
            .collect(Collectors.toList());
    }

    @EventListener
    public void handleMenuEntity(EntityModifyEvent<MenuEntity> e) {
        e.async(
            ClearUserAuthorizationCacheEvent.all().publish(eventPublisher)
        );
    }

    @EventListener
    public void handleMenuEntity(EntityDeletedEvent<MenuEntity> e) {
        e.async(
            ClearUserAuthorizationCacheEvent.all().publish(eventPublisher)
        );
    }

    @EventListener
    public void handleMenuEntity(EntitySavedEvent<MenuEntity> e) {
        e.async(
            ClearUserAuthorizationCacheEvent.all().publish(eventPublisher)
        );
    }

}

        if (CollectionUtils.isEmpty(dimensions)) {
            return Flux.empty();
        }
        List<String> keyList = dimensions
            .stream()
            .map(dimension -> MenuBindEntity.generateTargetKey(dimension.getType().getId(), dimension.getId()))
            .collect(Collectors.toList());

        return bindRepository
            .createQuery()
            .setParam(queryParam.noPaging())
            .where()
            .in(MenuBindEntity::getTargetKey, keyList)
            .fetch()
            .as(this::convertToView);
    
<no_super_class>