using System.ComponentModel.DataAnnotations;
using Tiku.Application.Scoreline;

namespace Tiku.Api.Contracts;

/// <summary>
///     分数线查询参数。
/// </summary>
public sealed class ScorelineQueryDto
{
    /// <summary>
    ///     租户编码。
    /// </summary>
    [StringLength(100)]
    public string? TenantCode { get; set; }

    /// <summary>
    ///     地区 ID。
    /// </summary>
    public Guid? RegionId { get; set; }

    /// <summary>
    ///     院校 ID。
    /// </summary>
    public Guid? SchoolId { get; set; }

    /// <summary>
    ///     专业 ID。
    /// </summary>
    public Guid? MajorId { get; set; }

    /// <summary>
    ///     关键字。
    /// </summary>
    [StringLength(100)]
    public string? Keyword { get; set; }

    /// <summary>
    ///     年份。
    /// </summary>
    [Range(1900, 3000)]
    public int? Year { get; set; }

    /// <summary>
    ///     页码。
    /// </summary>
    [Range(1, 10000)]
    public int? Page { get; set; }

    /// <summary>
    ///     每页数量。
    /// </summary>
    [Range(1, 200)]
    public int? PageSize { get; set; }

    /// <summary>
    ///     返回数量上限。
    /// </summary>
    [Range(1, 2000)]
    public int? Limit { get; set; }

    /// <summary>
    ///     版本化的不透明游标，仅用于游标分页接口。
    /// </summary>
    [StringLength(2000)]
    public string? Cursor { get; set; }

    public ScorelineFilter ToFilter(
        Guid tenantId,
        IReadOnlyCollection<ScorelineDynamicFilter>? dynamicFilters = null)
    {
        return new ScorelineFilter(
            tenantId,
            RegionId,
            SchoolId,
            MajorId,
            Keyword,
            Year,
            Page,
            PageSize,
            Limit,
            dynamicFilters);
    }
}