package cn.reghao.bnt.web.template;

import cn.reghao.bnt.web.admin.model.vo.MenuTree;
import cn.reghao.bnt.web.admin.service.MenuService;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * 后台页面侧边栏菜单
 *
 * @author reghao
 * @date 2025-06-03 11:30:49
 */
@Component
public class MenusDirective extends TemplateDirective {
    private final MenuService menuService;

    public MenusDirective(MenuService menuService) {
        this.menuService = menuService;
    }

    @Override
    public String getName() {
        return "menus";
    }

    @Override
    public void execute(DirectiveHandler handler) throws Exception {
        List<MenuTree> menuTrees = menuService.getSideMenus();
        handler.put("results", menuTrees).render();
    }
}
