mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 12:11:10 +00:00
Adds pagination and filtering to the API
This commit is contained in:
1 parent
ad984910a2
commit
ce4ebf36bc
59 files changed
+4423
-242
No files matched your search
@@ -0,0 +1,12 @@
|
||||
namespace Lumina.Contracts.DTO.Common.Filtering;
|
||||
|
||||
/// <summary>
|
||||
/// Data transfer object that defines common filter properties used when quering paginated data. Implementations may add additional properties specific to their module or domain.
|
||||
/// </summary>
|
||||
public record BaseFilterDto
|
||||
{
|
||||
/// <summary>
|
||||
/// The search term used to filter results.
|
||||
/// </summary>
|
||||
public string? SearchTerm { get; init; }
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using System;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Contracts.DTO.Common.Filtering;
|
||||
|
||||
/// <summary>
|
||||
/// Data transfer object that represents the parameters required to filter by library data.
|
||||
/// </summary>
|
||||
public record LibraryFilterDto : BaseFilterDto
|
||||
{
|
||||
/// <summary>
|
||||
/// The Id of the media library used to filter data.
|
||||
/// </summary>
|
||||
public required Guid LibraryId { get; init; }
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using System;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Contracts.DTO.Common.Pagination;
|
||||
|
||||
/// <summary>
|
||||
/// Data transfer object for pagination metadata.
|
||||
/// </summary>
|
||||
public sealed record PaginationDataDto
|
||||
{
|
||||
private int perPage = 200;
|
||||
private int currentPage = 1;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the current page number in a paginated collection.
|
||||
/// </summary>
|
||||
public int CurrentPage
|
||||
{
|
||||
get { return currentPage; }
|
||||
set
|
||||
{
|
||||
currentPage = Math.Max(value, 1);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the number of items to include per page in paginated results.
|
||||
/// </summary>
|
||||
public int PerPage
|
||||
{
|
||||
get { return perPage; }
|
||||
set
|
||||
{
|
||||
perPage = Math.Max(value, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.Common;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Contracts.Requests.MediaLibrary.WrittenContentLibrary.BookLibrary.Books;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a request to get the lightweight details of the books of a media library.
|
||||
/// </summary>
|
||||
/// <param name="LibraryId">The Id of the media library whose books are retrieved. Required.</param>
|
||||
/// <param name="CurrentPage">The page of results to retrieve. Optional.</param>
|
||||
/// <param name="PerPage">The maximum number of books to retrieve per page. Optional.</param>
|
||||
/// <param name="SearchTerm">The search term used to filter results. Optional.</param>
|
||||
/// <param name="SortBy">The name of the field by which to sort the results. Optional.</param>
|
||||
/// <param name="SortOrder">The direction in which to sort the results. Optional.</param>
|
||||
[DebuggerDisplay("LibraryId: {LibraryId}")]
|
||||
public record GetBooksLiteRequest(
|
||||
Guid LibraryId,
|
||||
int? CurrentPage,
|
||||
int? PerPage,
|
||||
string? SearchTerm,
|
||||
string? SortBy,
|
||||
SortOrder? SortOrder
|
||||
);
|
||||
+12
-1
@@ -1,4 +1,5 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.Common;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
#endregion
|
||||
@@ -9,7 +10,17 @@ namespace Lumina.Contracts.Requests.MediaLibrary.WrittenContentLibrary.BookLibra
|
||||
/// Represents a request to get the books of a media library.
|
||||
/// </summary>
|
||||
/// <param name="LibraryId">The Id of the media library whose books are retrieved. Required.</param>
|
||||
/// <param name="CurrentPage">The page of results to retrieve. Optional.</param>
|
||||
/// <param name="PerPage">The maximum number of books to retrieve per page. Optional.</param>
|
||||
/// <param name="SearchTerm">The search term used to filter results. Optional.</param>
|
||||
/// <param name="SortBy">The name of the field by which to sort the results. Optional.</param>
|
||||
/// <param name="SortOrder">The direction in which to sort the results. Optional.</param>
|
||||
[DebuggerDisplay("LibraryId: {LibraryId}")]
|
||||
public record GetBooksRequest(
|
||||
Guid LibraryId
|
||||
Guid LibraryId,
|
||||
int? CurrentPage,
|
||||
int? PerPage,
|
||||
string? SearchTerm,
|
||||
string? SortBy,
|
||||
SortOrder? SortOrder
|
||||
);
|
||||
@@ -0,0 +1,37 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using System.Collections.Generic;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Contracts.Responses.Common;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a paginated response containing a subset of data and pagination metadata for the current page.
|
||||
/// </summary>
|
||||
/// <typeparam name="TData">The type of the data items contained in the paginated response.</typeparam>
|
||||
public sealed record PaginatedResponse<TData>
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the collection of data items associated with this instance.
|
||||
/// </summary>
|
||||
public required IReadOnlyList<TData> Data { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the current page number in a paginated collection.
|
||||
/// </summary>
|
||||
public required int CurrentPage { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the number of items to include per page in paginated results.
|
||||
/// </summary>
|
||||
public required int PerPage { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the total number of elements available in the paginated result set.
|
||||
/// </summary>
|
||||
public required int Count { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the total number of pages based on elements available in the result set and per page.
|
||||
/// </summary>
|
||||
public required int NumberOfPages { get; init; }
|
||||
}
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Contracts.Responses.MediaLibrary.WrittenContentLibrary.BookLibrary.Books;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a lightweight book response, containing only the properties needed by the client for card-style navigation.
|
||||
/// </summary>
|
||||
/// <param name="Id">The Id of the book.</param>
|
||||
/// <param name="Title">The title of the book.</param>
|
||||
/// <param name="ReleaseYear">The release year of the book (re-release year, if available, or original release year), if known.</param>
|
||||
/// <param name="CoverPath">The path of the image representing the cover of the book, if available.</param>
|
||||
[DebuggerDisplay("Title: {Title}")]
|
||||
public record BookLiteResponse(
|
||||
Guid Id,
|
||||
string Title,
|
||||
int? ReleaseYear,
|
||||
string? CoverPath
|
||||
);
|
||||
Reference in new issue
Block a user