using System.ComponentModel.DataAnnotations;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Tiku.Api.Contracts;
using Tiku.Api.OpenApi;
using Tiku.Application.Auth;
using Tiku.Application.PlatformAdmin;
using Tiku.Application.Security;
using Tiku.Domain.Platform;

namespace Tiku.Api.Controllers;

[ApiController]
[Tags("平台端-平台管理")]
[Authorize(Policy = BackendPermissions.PlatformDashboardView)]
[Produces("application/json")]
[Route("api/platform")]
public sealed class PlatformDashboardController(
    IPlatformDashboardService service,
    PlatformAdminActorResolver actorResolver) : ControllerBase
{
    [HttpGet("overview")]
    [EndpointSummary("查询平台经营概览")]
    [ProducesResponseType<PlatformOverview>(StatusCodes.Status200OK)]
    public async Task<ActionResult<PlatformOverview>> Overview(CancellationToken cancellationToken)
    {
        return Ok(await service.GetOverviewAsync(actorResolver.Resolve(), cancellationToken));
    }
}
