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

namespace Tiku.Api.Contracts;

/// <summary>
/// 积分查询参数。
/// </summary>
public sealed class PointQueryDto
{
    /// <summary>
    /// 返回数量上限。
    /// </summary>
    [Range(1, 200)]
    public int? Limit { get; set; }

    /// <summary>
    /// 状态。
    /// </summary>
    [StringLength(32)]
    public string? Status { get; set; }

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

    public PointLimitQuery ToQuery()
    {
        return new PointLimitQuery(Limit, Status, RegionId);
    }
}

/// <summary>
/// 领取积分任务请求 DTO。
/// </summary>
public sealed class ClaimPointTaskDto
{
    /// <summary>
    /// 任务键。
    /// </summary>
    [Required]
    [StringLength(100)]
    public string TaskKey { get; set; } = string.Empty;

    /// <summary>
    /// 来源类型。
    /// </summary>
    [StringLength(100)]
    public string? SourceType { get; set; }

    /// <summary>
    /// 来源 ID。
    /// </summary>
    public Guid? SourceId { get; set; }

    public ClaimPointTaskCommand ToCommand()
    {
        return new ClaimPointTaskCommand(TaskKey, SourceType, SourceId);
    }
}

/// <summary>
/// 创建积分兑换订单请求 DTO。
/// </summary>
public sealed class CreatePointExchangeOrderDto
{
    /// <summary>
    /// 兑换项 ID。
    /// </summary>
    [Required]
    public Guid ItemId { get; set; }

    public CreatePointExchangeOrderCommand ToCommand()
    {
        return new CreatePointExchangeOrderCommand(ItemId);
    }
}
