using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Tiku.Api.Contracts;
using Tiku.Application.Auth;
using Tiku.Application.Catalog;
using Tiku.Application.Content;
using Tiku.Application.Security;
using Tiku.Application.TenantAdmin;

namespace Tiku.Api.Controllers;

[ApiController]
[Tags("租户端-运营管理")]
[Produces("application/json")]
[Route("api/tenant")]
public sealed class TenantAdminDashboardController(
    ITenantAdminDashboardService dashboardService,
    TenantAdminActorResolver actorResolver) : ControllerBase
{
    [HttpGet("overview")]
    [Authorize(Policy = BackendPermissions.TenantDashboardView)]
    [EndpointSummary("查询租户后台运营概览")]
    [ProducesResponseType<TenantAdminOverviewItem>(StatusCodes.Status200OK)]
    public async Task<ActionResult<TenantAdminOverviewItem>> GetOverview(CancellationToken cancellationToken)
    {
        return Ok(await dashboardService.GetOverviewAsync(actorResolver.Resolve(), cancellationToken));
    }
}

