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

namespace Tiku.Api.Contracts;

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

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

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

    /// <summary>
    ///     分类 ID。
    /// </summary>
    public Guid? CategoryId { get; set; }

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

    /// <summary>
    ///     题目 ID。
    /// </summary>
    public Guid? QuestionId { get; set; }

    /// <summary>
    ///     资产 ID。
    /// </summary>
    public Guid? AssetId { get; set; }

    /// <summary>
    ///     资产类型。
    /// </summary>
    [StringLength(50)]
    public string? AssetType { get; set; }

    /// <summary>
    ///     分类。
    /// </summary>
    [StringLength(100)]
    public string? Category { get; set; }

    /// <summary>
    ///     资产键。
    /// </summary>
    [StringLength(200)]
    public string? AssetKey { get; set; }

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

    /// <summary>
    ///     是否包含锁定资源。
    /// </summary>
    public bool IncludeLocked { get; set; }

    /// <summary>
    ///     是否包含停用数据。
    /// </summary>
    public bool IncludeInactive { get; set; }

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

    public AssetFilter ToFilter(Guid tenantId)
    {
        return new AssetFilter(
            tenantId,
            RegionId,
            SubjectId,
            CategoryId,
            ContentNodeId,
            QuestionId,
            AssetId,
            AssetType,
            Category,
            AssetKey,
            Keyword,
            IncludeLocked,
            IncludeInactive,
            Limit);
    }
}