// EN: Admin Resources Controller - Admin resource management APIs.
// VI: Controller Admin Resources - APIs quản trị tài nguyên.

using BookingService.API.Application.DTOs;
using BookingService.API.Application.Queries;
using BookingService.API.Models.Responses;
using MediatR;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;

namespace BookingService.API.Controllers.Admin;

[ApiController]
[Route("api/v1/admin/resources")]
[Produces("application/json")]
[Authorize(Roles = "Admin,ShopOwner")]
public class AdminResourcesController : ControllerBase
{
    private readonly IMediator _mediator;
    private readonly ILogger<AdminResourcesController> _logger;

    public AdminResourcesController(IMediator mediator, ILogger<AdminResourcesController> logger)
    {
        _mediator = mediator ?? throw new ArgumentNullException(nameof(mediator));
        _logger = logger ?? throw new ArgumentNullException(nameof(logger));
    }

    /// <summary>
    /// EN: Get all resources for a shop (including inactive).
    /// VI: Lấy tất cả tài nguyên của shop (bao gồm cả inactive).
    /// </summary>
    [HttpGet("{shopId:guid}")]
    [ProducesResponseType(typeof(ApiResponse<List<ResourceDto>>), StatusCodes.Status200OK)]
    public async Task<ActionResult<ApiResponse<List<ResourceDto>>>> GetAllResources(
        Guid shopId,
        CancellationToken cancellationToken = default)
    {
        var query = new GetResourcesByShopQuery(shopId, null); // null = get all (active + inactive)
        var result = await _mediator.Send(query, cancellationToken);

        return Ok(ApiResponse<List<ResourceDto>>.Ok(result));
    }
}
