using MediatR;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using SolutionErp.Application.Permissions;
using SolutionErp.Application.Permissions.Dtos;
using SolutionErp.Application.Permissions.Queries.GetMyMenuTree;

namespace SolutionErp.Api.Controllers;

[ApiController]
[Route("api/menus")]
[Authorize]
public class MenusController(IMediator mediator) : ControllerBase
{
    [HttpGet("me")]
    public async Task<ActionResult<List<MenuNodeDto>>> Me(CancellationToken ct)
        => Ok(await mediator.Send(new GetMyMenuTreeQuery(), ct));

    [HttpGet]
    public async Task<ActionResult<List<MenuItemDto>>> List(CancellationToken ct)
        => Ok(await mediator.Send(new ListMenuItemsQuery(), ct));
}
