namespace WebApi.Controllers.Dto;

public class PagedResponse<T> : BaseResponse<T[]>
{
    public long LastId { get; set; } = 0;
    
    /// <summary>
    /// 最后一条记录的时间（用于游标分页）
    /// </summary>
    public DateTime? LastTime { get; set; }

    /// <summary>
    /// 总记录数
    /// </summary>
    public int Total { get; set; }
    
    public new static PagedResponse<T> Fail(string message)
    {
        return new PagedResponse<T>
        {
            Success = false,
            Message = message
        };
    }

    public static PagedResponse<T> Done(T[] data, int total, long lastId = 0, DateTime? lastTime = null)
    {
        return new PagedResponse<T>
        {
            Success = true,
            Data = data,
            LastId = lastId,
            LastTime = lastTime,
            Total = total
        };
    }
}