using MediatR;

namespace AdsServingService.API.Application.Queries;

/// <summary>
/// EN: Query to get paginated list of auctions with filters.
/// VI: Query lấy danh sách auctions phân trang với bộ lọc.
/// </summary>
public class GetAuctionsQuery : IRequest<PagedResult<AuctionDto>>
{
    public Guid? UserId { get; init; }
    public string? PlacementType { get; init; }
    public DateTime? StartDate { get; init; }
    public DateTime? EndDate { get; init; }
    public int Page { get; init; } = 1;
    public int PageSize { get; init; } = 20;
}

public record AuctionDto
{
    public Guid Id { get; init; }
    public Guid UserId { get; init; }
    public string PlacementType { get; init; } = string.Empty;
    public DateTime AuctionTime { get; init; }
    public int BidCount { get; init; }
    public Guid? WinningAdId { get; init; }
    public decimal? FinalPrice { get; init; }
    public decimal? WinningeCPM { get; init; }
}

public record PagedResult<T>
{
    public List<T> 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(TotalCount / (double)PageSize);
}
