using MediatR;

namespace AdsManagerService.API.Application.Queries;

/// <summary>
/// EN: Query to list campaigns with filtering.
/// VI: Query liệt kê các chiến dịch với bộ lọc.
/// </summary>
public record ListCampaignsQuery : IRequest<ListCampaignsResult>
{
    /// <summary>
    /// EN: Filter by advertiser ID.
    /// VI: Lọc theo ID nhà quảng cáo.
    /// </summary>
    public Guid? AdvertiserId { get; init; }

    /// <summary>
    /// EN: Filter by status (Draft, Active, Paused, Completed, Archived).
    /// VI: Lọc theo trạng thái.
    /// </summary>
    public string? Status { get; init; }

    /// <summary>
    /// EN: Filter by objective (Awareness, Traffic, Conversion).
    /// VI: Lọc theo mục tiêu.
    /// </summary>
    public string? Objective { get; init; }

    /// <summary>
    /// EN: Search by campaign name.
    /// VI: Tìm kiếm theo tên chiến dịch.
    /// </summary>
    public string? SearchTerm { get; init; }

    /// <summary>
    /// EN: Page number (1-based).
    /// VI: Số trang (bắt đầu từ 1).
    /// </summary>
    public int Page { get; init; } = 1;

    /// <summary>
    /// EN: Page size.
    /// VI: Kích thước trang.
    /// </summary>
    public int PageSize { get; init; } = 20;
}

/// <summary>
/// EN: Result for list campaigns query.
/// VI: Kết quả cho query liệt kê chiến dịch.
/// </summary>
public record ListCampaignsResult
{
    public List<CampaignDto> Items { get; init; } = new();
    public int TotalCount { get; init; }
    public int Page { get; init; }
    public int PageSize { get; init; }
    public int TotalPages => (int)Math.Ceiling((double)TotalCount / PageSize);
}
