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

namespace Tiku.Api.Contracts;

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

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

    /// <summary>
    /// 单元 ID。
    /// </summary>
    public Guid? UnitId { get; set; }

    /// <summary>
    /// 科目 ID。
    /// </summary>
    public Guid? SubjectId { get; set; }

    /// <summary>
    /// 章节 ID。
    /// </summary>
    public Guid? ChapterId { get; set; }

    /// <summary>
    /// 内容入口 ID。
    /// </summary>
    public Guid? EntryId { get; set; }

    /// <summary>
    /// 内容节点 ID。
    /// </summary>
    public Guid? ContentNodeId { get; set; }

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

    /// <summary>
    /// 是否包含正文内容。
    /// </summary>
    public bool IncludeContent { get; set; }

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

    public StudyContentFilter ToFilter(Guid tenantId)
    {
        return new StudyContentFilter(
            tenantId,
            RegionId,
            UnitId,
            SubjectId,
            ChapterId,
            EntryId,
            ContentNodeId,
            Keyword,
            IncludeContent,
            Limit);
    }
}
