using Femto.Common.Domain;
using Femto.Modules.Blog.Application.Queries.GetPosts.Dto;

namespace Femto.Modules.Blog.Application.Queries.GetPosts;

/// <summary>
/// Get posts in reverse chronological order
/// </summary>
/// <param name="CurrentUserId"></param>
public record GetPostsQuery(Guid? CurrentUserId) : IQuery<GetPostsQueryResult>
{
    /// <summary>
    /// Id of the specific post to load. If specified, After and Amount are ignored
    /// </summary>
    public Guid? PostId { get; }
    
    /// <summary>
    /// If specified, loads posts from after the given Id. Used for paging
    /// </summary>
    public Guid? After { get; init; }
    public int Amount { get; init; } = 20;
    public Guid? AuthorId { get; init; }
    public string? Author { get; init; }

    public GetPostsQuery(Guid postId, Guid? currentUserId) : this(currentUserId)
    {
        this.PostId = postId;
    }
}