mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-02 08:01:10 +00:00
Refactors the get books and get books lite slices across the stack
This commit is contained in:
1 parent
001146eefc
commit
1d35cd01db
44 files changed
+1681
-418
No files matched your search
+31
@@ -0,0 +1,31 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using System;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.DTO.MediaLibrary.WrittenContentLibrary.BookLibrary;
|
||||
|
||||
/// <summary>
|
||||
/// Lightweight read model of a book, containing only the fields needed to display the book in a card-based grid or a list.
|
||||
/// </summary>
|
||||
public sealed record BookLiteRow
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the Id of the book.
|
||||
/// </summary>
|
||||
public required Guid Id { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the title of the book.
|
||||
/// </summary>
|
||||
public required string Title { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the release year of the book (re-release year, if available, or original release year), if known.
|
||||
/// </summary>
|
||||
public int? ReleaseYear { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the path of the image representing the cover of the book, if available.
|
||||
/// </summary>
|
||||
public string? CoverPath { get; init; }
|
||||
}
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Application.Common.DataAccess.Entities.Common;
|
||||
using Lumina.Application.Common.DTO.Filtering;
|
||||
using Lumina.Application.Common.DTO.Pagination;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.Common;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.DataAccess.Repositories.Common.Actions;
|
||||
|
||||
/// <summary>
|
||||
/// Interface defining the "get all lite" action for interacting with a generic persistence medium.
|
||||
/// It retrieves lightweight read models of the stored data, projecting only the fields needed to display
|
||||
/// the data in grids or card-based navigation, without loading the full entities and their related data.
|
||||
/// </summary>
|
||||
/// <typeparam name="TModel">The type stored in the persistence medium, which is projected into the lightweight read models. It should implement <see cref="IStorageEntity"/>.</typeparam>
|
||||
/// <typeparam name="TLiteRow">The type of the lightweight read models returned by the action.</typeparam>
|
||||
public interface IGetAllLiteRepositoryAction<TModel, TLiteRow> where TModel : IStorageEntity
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the lightweight read models of type <typeparamref name="TLiteRow"/>, projected from the data of type <typeparamref name="TModel"/> stored in the storage medium.
|
||||
/// </summary>
|
||||
/// <typeparam name="TFilter">The type of the filter carrying the criteria used to filter the results.</typeparam>
|
||||
/// <param name="paginationData">The pagination data that includes the current page and the number of items per page to retrieve. If <see langword="null"/>, all matching data is returned.</param>
|
||||
/// <param name="sortBy">The name of the field by which to sort the results.</param>
|
||||
/// <param name="sortOrder">The direction in which to sort the results.</param>
|
||||
/// <param name="filterModel">The model containing the parameters used to filter the results.</param>
|
||||
/// <param name="includeNavigationProperties">Whether the navigation properties of the entities should be loaded together with the entities themselves. Pass <see langword="false"/> to retrieve only the data stored directly on the entity rows.</param>
|
||||
/// <param name="shouldTrackEntities">Whether the retrieved entities should be tracked by the persistence medium, so that changes to them can be saved. Pass <see langword="false"/> for read-only scenarios, to avoid the tracking overhead.</param>
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
/// <returns>An <see cref="Result{TValue}"/> containing either a paginated result of type <typeparamref name="TLiteRow"/>, or an error.</returns>
|
||||
Task<Result<PaginatedResultDto<TLiteRow>>> GetAllLiteAsync<TFilter>(PaginationDataDto? paginationData = null, string? sortBy = null, SortOrder? sortOrder = null, TFilter? filterModel = null, bool includeNavigationProperties = false, bool shouldTrackEntities = false, CancellationToken cancellationToken = default) where TFilter : BaseFilterDto;
|
||||
}
|
||||
-42
@@ -256,46 +256,4 @@ public static class BookEntityMapping
|
||||
NumberOfPages = repositoryEntities.NumberOfPages
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts <paramref name="repositoryEntity"/> to <see cref="BookLiteResponse"/>.
|
||||
/// </summary>
|
||||
/// <param name="repositoryEntity">The repository entity to be converted.</param>
|
||||
/// <returns>The converted response entity.</returns>
|
||||
public static BookLiteResponse ToLiteResponse(this BookEntity repositoryEntity)
|
||||
{
|
||||
return new BookLiteResponse(
|
||||
repositoryEntity.Id,
|
||||
repositoryEntity.Title,
|
||||
repositoryEntity.ReReleaseYear ?? repositoryEntity.OriginalReleaseYear,
|
||||
repositoryEntity.BookArtwork.FirstOrDefault(artwork => artwork.ArtworkType == ArtworkType.Cover)?.FileName
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts <paramref name="repositoryEntities"/> to a collection of <see cref="BookLiteResponse"/>.
|
||||
/// </summary>
|
||||
/// <param name="repositoryEntities">The repository entities to be converted.</param>
|
||||
/// <returns>The converted reponses.</returns>
|
||||
public static IReadOnlyList<BookLiteResponse> ToLiteResponses(this IEnumerable<BookEntity> repositoryEntities)
|
||||
{
|
||||
return [.. repositoryEntities.Select(repositoryEntity => repositoryEntity.ToLiteResponse())];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts <paramref name="repositoryEntities"/> to a paginated collection of <see cref="BookLiteResponse"/>.
|
||||
/// </summary>
|
||||
/// <param name="repositoryEntities">The paginated repository entities to be converted.</param>
|
||||
/// <returns>The converted paginated responses.</returns>
|
||||
public static PaginatedResponse<BookLiteResponse> ToLiteResponses(this PaginatedResultDto<BookEntity> repositoryEntities)
|
||||
{
|
||||
return new PaginatedResponse<BookLiteResponse>
|
||||
{
|
||||
Data = repositoryEntities.Data.ToLiteResponses(),
|
||||
CurrentPage = repositoryEntities.CurrentPage,
|
||||
PerPage = repositoryEntities.PerPage,
|
||||
Count = repositoryEntities.Count,
|
||||
NumberOfPages = repositoryEntities.NumberOfPages
|
||||
};
|
||||
}
|
||||
}
|
||||
+57
@@ -0,0 +1,57 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.DTO.MediaLibrary.WrittenContentLibrary.BookLibrary;
|
||||
using Lumina.Application.Common.DTO.Pagination;
|
||||
using Lumina.Contracts.Responses.Common;
|
||||
using Lumina.Contracts.Responses.MediaLibrary.WrittenContentLibrary.BookLibrary.Books;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.Mapping.MediaLibrary.WrittenContentLibrary.BookLibrary.Books;
|
||||
|
||||
/// <summary>
|
||||
/// Extension methods for converting <see cref="BookLiteRow"/>.
|
||||
/// </summary>
|
||||
public static class BookLiteRowMapping
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts <paramref name="readModel"/> to <see cref="BookLiteResponse"/>.
|
||||
/// </summary>
|
||||
/// <param name="readModel">The read model to be converted.</param>
|
||||
/// <returns>The converted response.</returns>
|
||||
public static BookLiteResponse ToResponse(this BookLiteRow readModel)
|
||||
{
|
||||
return new BookLiteResponse(
|
||||
readModel.Id,
|
||||
readModel.Title,
|
||||
readModel.ReleaseYear,
|
||||
readModel.CoverPath);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts <paramref name="readModels"/> to a collection of <see cref="BookLiteResponse"/>.
|
||||
/// </summary>
|
||||
/// <param name="readModels">The read models to be converted.</param>
|
||||
/// <returns>The converted responses.</returns>
|
||||
public static IReadOnlyList<BookLiteResponse> ToResponses(this IEnumerable<BookLiteRow> readModels)
|
||||
{
|
||||
return [.. readModels.Select(readModel => readModel.ToResponse())];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts <paramref name="readModels"/> to a paginated collection of <see cref="BookLiteResponse"/>.
|
||||
/// </summary>
|
||||
/// <param name="readModels">The paginated read models to be converted.</param>
|
||||
/// <returns>The converted paginated responses.</returns>
|
||||
public static PaginatedResponse<BookLiteResponse> ToResponses(this PaginatedResultDto<BookLiteRow> readModels)
|
||||
{
|
||||
return new PaginatedResponse<BookLiteResponse>
|
||||
{
|
||||
Data = readModels.Data.ToResponses(),
|
||||
CurrentPage = readModels.CurrentPage,
|
||||
PerPage = readModels.PerPage,
|
||||
Count = readModels.Count,
|
||||
NumberOfPages = readModels.NumberOfPages
|
||||
};
|
||||
}
|
||||
}
|
||||
+11
-11
@@ -16,26 +16,26 @@ public static class GetBooksLiteRequestMapping
|
||||
/// Converts <paramref name="request"/> to <see cref="GetBooksLiteQuery"/>.
|
||||
/// </summary>
|
||||
/// <param name="request">The request to be converted.</param>
|
||||
/// <param name="libraryId">The Id of the library whose books are retrieved, taken from the route.</param>
|
||||
/// <returns>The converted query.</returns>
|
||||
public static GetBooksLiteQuery ToQuery(this GetBooksLiteRequest request)
|
||||
public static GetBooksLiteQuery ToQuery(this GetBooksLiteRequest request, string? libraryId)
|
||||
{
|
||||
PaginationDataDto? paginationData = null;
|
||||
if (request.CurrentPage is not null || request.PerPage is not null)
|
||||
{
|
||||
paginationData = new PaginationDataDto
|
||||
{
|
||||
CurrentPage = request.CurrentPage ?? 1,
|
||||
PerPage = request.PerPage ?? 200
|
||||
};
|
||||
}
|
||||
LibraryFilterDto libraryFilter = new()
|
||||
{
|
||||
LibraryId = request.LibraryId,
|
||||
SearchTerm = request.SearchTerm,
|
||||
FilterAlphaKey = request.FilterAlphaKey,
|
||||
ShouldIgnoreThePrefixForAlphaPicker = request.ShouldIgnoreThePrefixForAlphaPicker
|
||||
};
|
||||
|
||||
return new GetBooksLiteQuery(paginationData, libraryFilter, request.SortBy, request.SortOrder);
|
||||
return new GetBooksLiteQuery(
|
||||
libraryId,
|
||||
paginationData,
|
||||
request.SearchTerm,
|
||||
request.FilterAlphaKey,
|
||||
request.ShouldIgnoreThePrefixForAlphaPicker,
|
||||
request.SortBy,
|
||||
request.SortOrder
|
||||
);
|
||||
}
|
||||
}
|
||||
+3
-9
@@ -1,5 +1,4 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.DTO.Filtering;
|
||||
using Lumina.Application.Common.DTO.Pagination;
|
||||
using Lumina.Application.Core.MediaLibrary.WrittenContentLibrary.BookLibrary.Books.Queries.GetBooks;
|
||||
using Lumina.Contracts.Requests.MediaLibrary.WrittenContentLibrary.BookLibrary.Books;
|
||||
@@ -16,8 +15,9 @@ public static class GetBooksRequestMapping
|
||||
/// Converts <paramref name="request"/> to <see cref="GetBooksQuery"/>.
|
||||
/// </summary>
|
||||
/// <param name="request">The request to be converted.</param>
|
||||
/// <param name="libraryId">The Id of the library whose books are retrieved, taken from the route.</param>
|
||||
/// <returns>The converted query.</returns>
|
||||
public static GetBooksQuery ToQuery(this GetBooksRequest request)
|
||||
public static GetBooksQuery ToQuery(this GetBooksRequest request, string? libraryId)
|
||||
{
|
||||
PaginationDataDto? paginationData = null;
|
||||
if (request.CurrentPage is not null || request.PerPage is not null)
|
||||
@@ -27,12 +27,6 @@ public static class GetBooksRequestMapping
|
||||
PerPage = request.PerPage ?? 200
|
||||
};
|
||||
|
||||
LibraryFilterDto libraryFilter = new()
|
||||
{
|
||||
LibraryId = request.LibraryId,
|
||||
SearchTerm = request.SearchTerm
|
||||
};
|
||||
|
||||
return new GetBooksQuery(paginationData, libraryFilter, request.SortBy, request.SortOrder);
|
||||
return new GetBooksQuery(libraryId, paginationData, request.SearchTerm, request.SortBy, request.SortOrder);
|
||||
}
|
||||
}
|
||||
+4
-3
@@ -1,6 +1,5 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.CQRS;
|
||||
using Lumina.Application.Common.DTO.Filtering;
|
||||
using Lumina.Application.Common.DTO.Pagination;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.Common;
|
||||
#endregion
|
||||
@@ -10,13 +9,15 @@ namespace Lumina.Application.Core.MediaLibrary.WrittenContentLibrary.BookLibrary
|
||||
/// <summary>
|
||||
/// Query for getting all the books of a media library.
|
||||
/// </summary>
|
||||
/// <param name="LibraryId">The unique identifier of the media library whose books are retrieved, taken from the route.</param>
|
||||
/// <param name="PaginationData">The object containing the requested pagination data.</param>
|
||||
/// <param name="Filter">The object containing the criteria used to filter the results.</param>
|
||||
/// <param name="SearchTerm">The search term used to filter results.</param>
|
||||
/// <param name="SortBy">The name of the field by which to sort the results.</param>
|
||||
/// <param name="SortOrder">The direction in which to sort the results.</param>
|
||||
public record GetBooksQuery(
|
||||
string? LibraryId,
|
||||
PaginationDataDto? PaginationData,
|
||||
LibraryFilterDto Filter,
|
||||
string? SearchTerm,
|
||||
string? SortBy,
|
||||
SortOrder? SortOrder
|
||||
) : IQuery;
|
||||
+17
-7
@@ -16,6 +16,7 @@ using Lumina.Application.Common.Infrastructure.Authorization;
|
||||
using Lumina.Application.Common.Infrastructure.Authorization.Policies.LibraryOwnership;
|
||||
using Lumina.Application.Common.Infrastructure.Validation;
|
||||
using Lumina.Application.Common.Errors;
|
||||
using Lumina.Application.Common.DTO.Filtering;
|
||||
using Lumina.Application.Common.DTO.Pagination;
|
||||
#endregion
|
||||
|
||||
@@ -60,25 +61,34 @@ public class GetBooksQueryHandler : IQueryHandler<GetBooksQuery, Result<Paginate
|
||||
if (validationResult.Count > 0)
|
||||
return validationResult;
|
||||
|
||||
// an authenticated request must always carry a user identity
|
||||
// An authenticated request must always carry a user identity.
|
||||
Guid? currentUserId = _currentUserService.UserId;
|
||||
if (currentUserId is null)
|
||||
return Errors.Authorization.NotAuthorized;
|
||||
Guid userId = currentUserId.Value;
|
||||
|
||||
// admins can see all libraries; for everyone else, only the libraries they own
|
||||
// The validator guarantees that the library id of the route is a non-empty Guid before this point.
|
||||
Guid libraryId = Guid.Parse(query.LibraryId!);
|
||||
|
||||
// Admins can see all libraries; for everyone else, only the libraries they own.
|
||||
bool canAccessLibrary = await _authorizationService.EvaluatePolicyAsync<ILibraryOwnershipPolicy>(
|
||||
userId, new LibraryOwnershipPolicyContext(query.Filter.LibraryId), cancellationToken).ConfigureAwait(false);
|
||||
userId, new LibraryOwnershipPolicyContext(libraryId), cancellationToken).ConfigureAwait(false);
|
||||
if (!canAccessLibrary)
|
||||
return Errors.Authorization.NotAuthorized;
|
||||
|
||||
// get all books of the media library from the book repository
|
||||
Result<PaginatedResultDto<BookEntity>> getBooksResult = await _unitOfWork.BookRepository.GetPaginatedAsync(
|
||||
// Get all books of the media library from the book repository.
|
||||
LibraryFilterDto libraryFilter = new()
|
||||
{
|
||||
LibraryId = libraryId,
|
||||
SearchTerm = query.SearchTerm
|
||||
};
|
||||
Result<PaginatedResultDto<BookEntity>> getBooksResult = await _unitOfWork.BookRepository.GetAllAsync(
|
||||
query.PaginationData,
|
||||
query.SortBy,
|
||||
query.SortOrder,
|
||||
query.Filter,
|
||||
cancellationToken).ConfigureAwait(false);
|
||||
libraryFilter,
|
||||
shouldTrackEntities: false,
|
||||
cancellationToken: cancellationToken).ConfigureAwait(false);
|
||||
return getBooksResult.Match(value => Result.From(value.ToResponses()), errors => errors);
|
||||
}
|
||||
}
|
||||
+7
-3
@@ -17,10 +17,14 @@ public class GetBooksQueryValidator : AbstractValidator<GetBooksQuery>
|
||||
/// </summary>
|
||||
public GetBooksQueryValidator()
|
||||
{
|
||||
RuleFor(query => query.Filter.LibraryId)
|
||||
// Validates the identifier of the media library whose books are retrieved, taken from the route.
|
||||
RuleFor(query => query.LibraryId)
|
||||
.NotEmpty()
|
||||
.WithError(Errors.Library.LibraryIdCannotBeEmpty)
|
||||
.Must(id => id != Guid.Empty)
|
||||
.WithError(Errors.Library.LibraryIdCannotBeEmpty);
|
||||
|
||||
RuleFor(query => query.LibraryId)
|
||||
.Must(libraryId => Guid.TryParse(libraryId, out Guid parsedLibraryId) && parsedLibraryId != Guid.Empty)
|
||||
.When(query => query.LibraryId is not null && query.LibraryId.Length > 0)
|
||||
.WithError(Errors.Library.LibraryIdCannotBeEmpty);
|
||||
}
|
||||
}
|
||||
+8
-3
@@ -1,6 +1,5 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.CQRS;
|
||||
using Lumina.Application.Common.DTO.Filtering;
|
||||
using Lumina.Application.Common.DTO.Pagination;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.Common;
|
||||
#endregion
|
||||
@@ -10,13 +9,19 @@ namespace Lumina.Application.Core.MediaLibrary.WrittenContentLibrary.BookLibrary
|
||||
/// <summary>
|
||||
/// Query for getting the lightweight details of all the books of a media library.
|
||||
/// </summary>
|
||||
/// <param name="LibraryId">The unique identifier of the media library whose books are retrieved, taken from the route.</param>
|
||||
/// <param name="PaginationData">The object containing the requested pagination data.</param>
|
||||
/// <param name="Filter">The object containing the criteria used to filter the results.</param>
|
||||
/// <param name="SearchTerm">The search term used to filter results.</param>
|
||||
/// <param name="FilterAlphaKey">The alpha key used to filter results by the first character of their title.</param>
|
||||
/// <param name="ShouldIgnoreThePrefixForAlphaPicker">Whether the leading "The " prefix of a title should be ignored when computing the alpha key, or not.</param>
|
||||
/// <param name="SortBy">The name of the field by which to sort the results.</param>
|
||||
/// <param name="SortOrder">The direction in which to sort the results.</param>
|
||||
public record GetBooksLiteQuery(
|
||||
string? LibraryId,
|
||||
PaginationDataDto? PaginationData,
|
||||
LibraryFilterDto Filter,
|
||||
string? SearchTerm,
|
||||
string? FilterAlphaKey,
|
||||
bool ShouldIgnoreThePrefixForAlphaPicker,
|
||||
string? SortBy,
|
||||
SortOrder? SortOrder
|
||||
) : IQuery;
|
||||
+22
-9
@@ -1,7 +1,7 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Application.Common.CQRS;
|
||||
using Lumina.Application.Common.DataAccess.Entities.MediaLibrary.WrittenContentLibrary.BookLibrary;
|
||||
using Lumina.Application.Common.DTO.MediaLibrary.WrittenContentLibrary.BookLibrary;
|
||||
using Lumina.Application.Common.DataAccess.Repositories.Books;
|
||||
using Lumina.Application.Common.DataAccess.UoW;
|
||||
using Lumina.Application.Common.Mapping.MediaLibrary.WrittenContentLibrary.BookLibrary.Books;
|
||||
@@ -16,6 +16,7 @@ using Lumina.Application.Common.Infrastructure.Authorization;
|
||||
using Lumina.Application.Common.Infrastructure.Authorization.Policies.LibraryOwnership;
|
||||
using Lumina.Application.Common.Infrastructure.Validation;
|
||||
using Lumina.Application.Common.Errors;
|
||||
using Lumina.Application.Common.DTO.Filtering;
|
||||
using Lumina.Application.Common.DTO.Pagination;
|
||||
#endregion
|
||||
|
||||
@@ -60,25 +61,37 @@ public class GetBooksLiteQueryHandler : IQueryHandler<GetBooksLiteQuery, Result<
|
||||
if (validationResult.Count > 0)
|
||||
return validationResult;
|
||||
|
||||
// an authenticated request must always carry a user identity
|
||||
// An authenticated request must always carry a user identity.
|
||||
Guid? currentUserId = _currentUserService.UserId;
|
||||
if (currentUserId is null)
|
||||
return Errors.Authorization.NotAuthorized;
|
||||
Guid userId = currentUserId.Value;
|
||||
|
||||
// admins can see all libraries; for everyone else, only the libraries they own
|
||||
// The validator guarantees that the library id of the route is a non-empty Guid before this point.
|
||||
Guid libraryId = Guid.Parse(query.LibraryId!);
|
||||
|
||||
// Admins can see all libraries; for everyone else, only the libraries they own.
|
||||
bool canAccessLibrary = await _authorizationService.EvaluatePolicyAsync<ILibraryOwnershipPolicy>(
|
||||
userId, new LibraryOwnershipPolicyContext(query.Filter.LibraryId), cancellationToken).ConfigureAwait(false);
|
||||
userId, new LibraryOwnershipPolicyContext(libraryId), cancellationToken).ConfigureAwait(false);
|
||||
if (!canAccessLibrary)
|
||||
return Errors.Authorization.NotAuthorized;
|
||||
|
||||
// get all books of the media library from the book repository
|
||||
Result<PaginatedResultDto<BookEntity>> getBooksResult = await _unitOfWork.BookRepository.GetPaginatedAsync(
|
||||
LibraryFilterDto libraryFilter = new()
|
||||
{
|
||||
LibraryId = libraryId,
|
||||
SearchTerm = query.SearchTerm,
|
||||
FilterAlphaKey = query.FilterAlphaKey,
|
||||
ShouldIgnoreThePrefixForAlphaPicker = query.ShouldIgnoreThePrefixForAlphaPicker
|
||||
};
|
||||
|
||||
// Get the lightweight read models of the books of the media library from the book repository, projecting only the fields needed for a grid or a list.
|
||||
Result<PaginatedResultDto<BookLiteRow>> getBooksResult = await _unitOfWork.BookRepository.GetAllLiteAsync(
|
||||
query.PaginationData,
|
||||
query.SortBy,
|
||||
query.SortOrder,
|
||||
query.Filter,
|
||||
cancellationToken).ConfigureAwait(false);
|
||||
return getBooksResult.Match(value => Result.From(value.ToLiteResponses()), errors => errors);
|
||||
libraryFilter,
|
||||
shouldTrackEntities: false,
|
||||
cancellationToken: cancellationToken).ConfigureAwait(false);
|
||||
return getBooksResult.Match(value => Result.From(value.ToResponses()), errors => errors);
|
||||
}
|
||||
}
|
||||
+8
-4
@@ -18,15 +18,19 @@ public class GetBooksLiteQueryValidator : AbstractValidator<GetBooksLiteQuery>
|
||||
/// </summary>
|
||||
public GetBooksLiteQueryValidator()
|
||||
{
|
||||
RuleFor(query => query.Filter.LibraryId)
|
||||
// Validates the identifier of the media library whose books are retrieved, taken from the route.
|
||||
RuleFor(query => query.LibraryId)
|
||||
.NotEmpty()
|
||||
.WithError(Errors.Library.LibraryIdCannotBeEmpty)
|
||||
.Must(id => id != Guid.Empty)
|
||||
.WithError(Errors.Library.LibraryIdCannotBeEmpty);
|
||||
|
||||
RuleFor(query => query.LibraryId)
|
||||
.Must(libraryId => Guid.TryParse(libraryId, out Guid parsedLibraryId) && parsedLibraryId != Guid.Empty)
|
||||
.When(query => query.LibraryId is not null && query.LibraryId.Length > 0)
|
||||
.WithError(Errors.Library.LibraryIdCannotBeEmpty);
|
||||
|
||||
// the alpha key must be exactly one of the three picker bucket kinds, so that the filter specification can
|
||||
// derive the key of a title unambiguously: no filter, a number bucket, a symbol bucket, or a single ASCII letter
|
||||
RuleFor(query => query.Filter.FilterAlphaKey)
|
||||
RuleFor(query => query.FilterAlphaKey)
|
||||
.Must(alphaKey => alphaKey is null
|
||||
|| alphaKey == LibraryItemAlphaKeys.NUMBER
|
||||
|| alphaKey == LibraryItemAlphaKeys.SYMBOL
|
||||
|
||||
+1
-4
@@ -1,6 +1,5 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.Common;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
#endregion
|
||||
|
||||
@@ -9,7 +8,6 @@ namespace Lumina.Contracts.Requests.MediaLibrary.WrittenContentLibrary.BookLibra
|
||||
/// <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>
|
||||
@@ -21,9 +19,8 @@ namespace Lumina.Contracts.Requests.MediaLibrary.WrittenContentLibrary.BookLibra
|
||||
/// <param name="ShouldIgnoreThePrefixForAlphaPicker">Whether the leading "The " prefix of a title should be ignored when computing the alpha key, or not.</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}")]
|
||||
[DebuggerDisplay("SearchTerm: {SearchTerm}")]
|
||||
public record GetBooksLiteRequest(
|
||||
Guid LibraryId,
|
||||
int? CurrentPage,
|
||||
int? PerPage,
|
||||
string? SearchTerm,
|
||||
|
||||
+1
-4
@@ -1,6 +1,5 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.Common;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
#endregion
|
||||
|
||||
@@ -9,15 +8,13 @@ namespace Lumina.Contracts.Requests.MediaLibrary.WrittenContentLibrary.BookLibra
|
||||
/// <summary>
|
||||
/// 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}")]
|
||||
[DebuggerDisplay("SearchTerm: {SearchTerm}")]
|
||||
public record GetBooksRequest(
|
||||
Guid LibraryId,
|
||||
int? CurrentPage,
|
||||
int? PerPage,
|
||||
string? SearchTerm,
|
||||
|
||||
@@ -105,7 +105,6 @@ internal sealed class BookRepository : IBookRepository
|
||||
return await query.FirstOrDefaultAsync(book => book.Id == id, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <summary>
|
||||
/// Gets paginated books, or all the books of the matching filters when the pagination data is <see langword="null"/>.
|
||||
/// </summary>
|
||||
@@ -191,18 +190,32 @@ internal sealed class BookRepository : IBookRepository
|
||||
/// <param name="sortBy">The name of the fields by which to sort the results.</param>
|
||||
/// <param name="sortOrder">The direction in which to sort the results.</param>
|
||||
/// <param name="filterModel">The model containing the parameters used to filter the results.</param>
|
||||
/// <param name="includeNavigationProperties">Whether the navigation properties of the entities should be loaded together with the entities themselves. Pass <see langword="false"/> to retrieve only the data stored directly on the entity rows.</param>
|
||||
/// <param name="shouldTrackEntities">Whether the retrieved entities should be tracked by the persistence medium, so that changes to them can be saved. Pass <see langword="false"/> for read-only scenarios, to avoid the tracking overhead.</param>
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
/// <returns>An <see cref="Result{TValue}"/> containing either a <see cref="PaginatedResultDto{BookLiteRow}"/>, or an error.</returns>
|
||||
public async Task<Result<PaginatedResultDto<BookLiteRow>>> GetAllLiteAsync<TFilter>(PaginationDataDto? paginationData = null, string? sortBy = null, SortOrder? sortOrder = null, TFilter? filterModel = null, CancellationToken cancellationToken = default) where TFilter : BaseFilterDto
|
||||
public async Task<Result<PaginatedResultDto<BookLiteRow>>> GetAllLiteAsync<TFilter>(PaginationDataDto? paginationData = null, string? sortBy = null, SortOrder? sortOrder = null, TFilter? filterModel = null, bool includeNavigationProperties = false, bool shouldTrackEntities = false, CancellationToken cancellationToken = default) where TFilter : BaseFilterDto
|
||||
{
|
||||
// Books should always be retrieved only per owning libraries.
|
||||
if (filterModel is not LibraryFilterDto libraryFilter || libraryFilter.LibraryId == Guid.Empty)
|
||||
return Errors.Library.FilterMustIncludeLibraryId;
|
||||
|
||||
// The lightweight read models are always retrieved without tracking, because they are never modified by the caller.
|
||||
IQueryable<BookEntity> booksQuery = _luminaDbContext.Books
|
||||
.AsNoTracking()
|
||||
.Where(book => book.LibraryId == libraryFilter.LibraryId);
|
||||
// The lightweight read models are retrieved without tracking by default, because they are never modified by the caller.
|
||||
IQueryable<BookEntity> booksQuery = _luminaDbContext.Books;
|
||||
if (!shouldTrackEntities)
|
||||
booksQuery = booksQuery.AsNoTracking();
|
||||
if (includeNavigationProperties)
|
||||
{
|
||||
booksQuery = booksQuery
|
||||
.Include(book => book.Tags)
|
||||
.Include(book => book.Genres)
|
||||
.Include(book => book.ISBNs)
|
||||
.Include(book => book.Ratings)
|
||||
.Include(book => book.BookContributors)
|
||||
.Include(book => book.BookArtwork);
|
||||
}
|
||||
|
||||
booksQuery = booksQuery.Where(book => book.LibraryId == libraryFilter.LibraryId);
|
||||
|
||||
FilterSpecification<BookEntity>? filterSpecification = BuildFilterSpecification(libraryFilter);
|
||||
if (filterSpecification is not null)
|
||||
|
||||
+6
-4
@@ -18,7 +18,7 @@ using System.Threading.Tasks;
|
||||
namespace Lumina.Presentation.Api.Core.Endpoints.Library.WrittenContentLibrary.BookLibrary.Books.GetBooks;
|
||||
|
||||
/// <summary>
|
||||
/// API endpoint for the <c>/books</c> route.
|
||||
/// API endpoint for the <c>/{libraryId}/books</c> route.
|
||||
/// </summary>
|
||||
public class GetBooksEndpoint : BaseEndpoint<GetBooksRequest, IResult>
|
||||
{
|
||||
@@ -45,13 +45,15 @@ public class GetBooksEndpoint : BaseEndpoint<GetBooksRequest, IResult>
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the list of all the books of the media library identified by <paramref name="request"/>.
|
||||
/// Gets the list of all the books of the media library identified by the <c>libraryId</c> route parameter.
|
||||
/// </summary>
|
||||
/// <param name="request">The request containing the Id of the media library whose books are retrieved.</param>
|
||||
/// <param name="request">The request containing the filtering and pagination options of the books to be retrieved.</param>
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
public override async Task<IResult> ExecuteAsync(GetBooksRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
Result<PaginatedResponse<BookResponse>> result = await _getBooksQueryHandler.HandleAsync(request.ToQuery(), cancellationToken).ConfigureAwait(false);
|
||||
// Take unique identifiers from the route.
|
||||
string? libraryId = HttpContext.Request.RouteValues["libraryId"]?.ToString();
|
||||
Result<PaginatedResponse<BookResponse>> result = await _getBooksQueryHandler.HandleAsync(request.ToQuery(libraryId), cancellationToken).ConfigureAwait(false);
|
||||
return result.Match(success => TypedResults.Ok(success), Problem);
|
||||
}
|
||||
}
|
||||
+37
-49
@@ -27,25 +27,29 @@ public class GetBooksEndpointSummary : Summary<GetBooksEndpoint, GetBooksRequest
|
||||
/// </summary>
|
||||
public GetBooksEndpointSummary()
|
||||
{
|
||||
Summary = "Retrieves the list of books.";
|
||||
Description = "Returns the entire list of books.";
|
||||
Summary = "Retrieves the list of books of a media library.";
|
||||
Description = "Returns the paginated, filterable list of the books of the media library identified by the request, with the full details of each book. The page is returned to an Admin, who can see the books of all libraries, or to the owner of the library.";
|
||||
|
||||
ExampleRequest = new GetBooksRequest(
|
||||
LibraryId: Guid.NewGuid(),
|
||||
CurrentPage: 1,
|
||||
PerPage: 48,
|
||||
PerPage: 10,
|
||||
SearchTerm: "fellowship",
|
||||
SortBy: "title",
|
||||
SortOrder: SortOrder.Ascending
|
||||
);
|
||||
|
||||
RequestParam(r => r.LibraryId, "The Id of the media library whose books are retrieved. Required.");
|
||||
RequestParam(r => r.CurrentPage, "The page of results to retrieve. Optional.");
|
||||
RequestParam(r => r.PerPage, "The maximum number of books to retrieve per page. Optional.");
|
||||
RequestParam(r => r.SearchTerm, "The search term used to filter results. Optional.");
|
||||
RequestParam(r => r.SortBy, "The name of the field by which to sort the results. Optional.");
|
||||
RequestParam(r => r.SortOrder, "The direction in which to sort the results. Optional.");
|
||||
|
||||
ResponseParam<PaginatedResponse<BookResponse>>(r => r.Data, "The books on the current page, each with the full details of the book.");
|
||||
ResponseParam<PaginatedResponse<BookResponse>>(r => r.CurrentPage, "The current page number.");
|
||||
ResponseParam<PaginatedResponse<BookResponse>>(r => r.PerPage, "The number of books retrieved per page.");
|
||||
ResponseParam<PaginatedResponse<BookResponse>>(r => r.Count, "The total number of books matching the request.");
|
||||
ResponseParam<PaginatedResponse<BookResponse>>(r => r.NumberOfPages, "The total number of pages.");
|
||||
|
||||
Response(200, "The paginated list of books is returned.",
|
||||
example: new PaginatedResponse<BookResponse>
|
||||
{
|
||||
@@ -93,9 +97,7 @@ public class GetBooksEndpointSummary : Summary<GetBooksEndpoint, GetBooksRequest
|
||||
Format: BookFormat.Paperback,
|
||||
Edition: "50th Anniversary Edition",
|
||||
VolumeNumber: 1,
|
||||
Series: new BookSeriesDto(
|
||||
Title: "The Lord of the Rings"
|
||||
),
|
||||
Series: null,
|
||||
ASIN: "B007978NPG",
|
||||
GoodreadsId: "3",
|
||||
LCCN: "54009621",
|
||||
@@ -117,24 +119,12 @@ public class GetBooksEndpointSummary : Summary<GetBooksEndpoint, GetBooksRequest
|
||||
],
|
||||
Contributors: [
|
||||
new(
|
||||
Name: new MediaContributorNameDto(
|
||||
DisplayName: "J.R.R. Tolkien",
|
||||
LegalName: "John Ronald Reuel Tolkien"
|
||||
),
|
||||
Role: new MediaContributorRoleDto(
|
||||
Name: "author",
|
||||
Category: MediaContributorRoleCategory.Author
|
||||
)
|
||||
ContributorId: Guid.NewGuid(),
|
||||
Role: MediaContributorRole.Author
|
||||
),
|
||||
new(
|
||||
Name: new MediaContributorNameDto(
|
||||
DisplayName: "Alan Lee",
|
||||
LegalName: "Alan Lee"
|
||||
),
|
||||
Role: new MediaContributorRoleDto(
|
||||
Name: "illustrator",
|
||||
Category: MediaContributorRoleCategory.Illustrator
|
||||
)
|
||||
ContributorId: Guid.NewGuid(),
|
||||
Role: MediaContributorRole.Illustrator
|
||||
)
|
||||
],
|
||||
Ratings: [
|
||||
@@ -200,9 +190,7 @@ public class GetBooksEndpointSummary : Summary<GetBooksEndpoint, GetBooksRequest
|
||||
Format: BookFormat.Hardcover,
|
||||
Edition: "50th Anniversary Edition",
|
||||
VolumeNumber: 2,
|
||||
Series: new BookSeriesDto(
|
||||
Title: "The Lord of the Rings"
|
||||
),
|
||||
Series: null,
|
||||
ASIN: "B007978NPZ",
|
||||
GoodreadsId: "33",
|
||||
LCCN: "54009622",
|
||||
@@ -224,24 +212,12 @@ public class GetBooksEndpointSummary : Summary<GetBooksEndpoint, GetBooksRequest
|
||||
],
|
||||
Contributors: [
|
||||
new(
|
||||
Name: new MediaContributorNameDto(
|
||||
DisplayName: "J.R.R. Tolkien",
|
||||
LegalName: "John Ronald Reuel Tolkien"
|
||||
),
|
||||
Role: new MediaContributorRoleDto(
|
||||
Name: "author",
|
||||
Category: MediaContributorRoleCategory.Author
|
||||
)
|
||||
ContributorId: Guid.NewGuid(),
|
||||
Role: MediaContributorRole.Author
|
||||
),
|
||||
new(
|
||||
Name: new MediaContributorNameDto(
|
||||
DisplayName: "Alan Lee",
|
||||
LegalName: "Alan Lee"
|
||||
),
|
||||
Role: new MediaContributorRoleDto(
|
||||
Name: "illustrator",
|
||||
Category: MediaContributorRoleCategory.Illustrator
|
||||
)
|
||||
ContributorId: Guid.NewGuid(),
|
||||
Role: MediaContributorRole.Illustrator
|
||||
)
|
||||
],
|
||||
Ratings: [
|
||||
@@ -282,16 +258,16 @@ public class GetBooksEndpointSummary : Summary<GetBooksEndpoint, GetBooksRequest
|
||||
type = "https://tools.ietf.org/html/rfc7235#section-3.1",
|
||||
status = 401,
|
||||
title = "Unauthorized",
|
||||
detail = "You are not authorized",
|
||||
instance = "/api/v1/books"
|
||||
detail = "Authentication failed",
|
||||
instance = $"/api/v1/libraries/{Guid.NewGuid()}/books"
|
||||
},
|
||||
new
|
||||
{
|
||||
type = "https://tools.ietf.org/html/rfc7235#section-3.1",
|
||||
status = 401,
|
||||
title = "Unauthorized",
|
||||
detail = "Invalid token: The token expired at '01/01/2024 01:00:00'",
|
||||
instance = "/api/v1/books"
|
||||
detail = "The token has expired",
|
||||
instance = $"/api/v1/libraries/{Guid.NewGuid()}/books"
|
||||
},
|
||||
new
|
||||
{
|
||||
@@ -299,11 +275,23 @@ public class GetBooksEndpointSummary : Summary<GetBooksEndpoint, GetBooksRequest
|
||||
status = 401,
|
||||
title = "Unauthorized",
|
||||
detail = "The token is invalid",
|
||||
instance = "/api/v1/books"
|
||||
instance = $"/api/v1/libraries/{Guid.NewGuid()}/books"
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
Response(403, "The request failed because the user making the request is not an Admin, or the owner of the media library.", "application/problem+json",
|
||||
example: new
|
||||
{
|
||||
type = "https://tools.ietf.org/html/rfc9110#section-15.5.4",
|
||||
title = "General.Unauthorized",
|
||||
status = 403,
|
||||
detail = "NotAuthorized",
|
||||
instance = $"/api/v1/libraries/{Guid.NewGuid()}/books",
|
||||
traceId = "00-a712bbf99ca8ab485f86a762ae5ae74d-b3a2eb78813b0a5d-00"
|
||||
}
|
||||
);
|
||||
|
||||
Response(422, "The request did not pass validation checks.", "application/problem+json",
|
||||
example: new
|
||||
{
|
||||
@@ -311,7 +299,7 @@ public class GetBooksEndpointSummary : Summary<GetBooksEndpoint, GetBooksRequest
|
||||
title = "General.Validation",
|
||||
status = 422,
|
||||
detail = "OneOrMoreValidationErrorsOccurred",
|
||||
instance = "/api/v1/books",
|
||||
instance = $"/api/v1/libraries/{Guid.NewGuid()}/books",
|
||||
errors = new Dictionary<string, string[]>
|
||||
{
|
||||
{
|
||||
|
||||
+6
-4
@@ -17,7 +17,7 @@ using System.Threading.Tasks;
|
||||
namespace Lumina.Presentation.Api.Core.Endpoints.Library.WrittenContentLibrary.BookLibrary.Books.GetBooksLite;
|
||||
|
||||
/// <summary>
|
||||
/// API endpoint for the <c>/books/lite</c> route.
|
||||
/// API endpoint for the <c>/{libraryId}/books/lite</c> route.
|
||||
/// </summary>
|
||||
public class GetBooksLiteEndpoint : BaseEndpoint<GetBooksLiteRequest, IResult>
|
||||
{
|
||||
@@ -44,13 +44,15 @@ public class GetBooksLiteEndpoint : BaseEndpoint<GetBooksLiteRequest, IResult>
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the lightweight details of all the books of the media library identified by <paramref name="request"/>.
|
||||
/// Gets the lightweight details of all the books of the media library identified by the <c>libraryId</c> route parameter.
|
||||
/// </summary>
|
||||
/// <param name="request">The request containing the Id of the media library whose books are retrieved.</param>
|
||||
/// <param name="request">The request containing the filtering and pagination options of the books to be retrieved.</param>
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
public override async Task<IResult> ExecuteAsync(GetBooksLiteRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
Result<PaginatedResponse<BookLiteResponse>> result = await _getBooksLiteQueryHandler.HandleAsync(request.ToQuery(), cancellationToken).ConfigureAwait(false);
|
||||
// Take unique identifiers from the route.
|
||||
string? libraryId = HttpContext.Request.RouteValues["libraryId"]?.ToString();
|
||||
Result<PaginatedResponse<BookLiteResponse>> result = await _getBooksLiteQueryHandler.HandleAsync(request.ToQuery(libraryId), cancellationToken).ConfigureAwait(false);
|
||||
return result.Match(success => TypedResults.Ok(success), Problem);
|
||||
}
|
||||
}
|
||||
+27
-11
@@ -22,13 +22,12 @@ public class GetBooksLiteEndpointSummary : Summary<GetBooksLiteEndpoint, GetBook
|
||||
/// </summary>
|
||||
public GetBooksLiteEndpointSummary()
|
||||
{
|
||||
Summary = "Retrieves the lightweight details of the list of books.";
|
||||
Description = "Returns a paginated list of the lightweight details of the books of the media library, suitable for card-style navigation.";
|
||||
Summary = "Retrieves the list of lightweight book details of a media library.";
|
||||
Description = "Returns the paginated, filterable list of the lightweight details of the books of the media library identified by the request, suitable for card-style navigation. The page is returned to an Admin, who can see the books of all libraries, or to the owner of the library.";
|
||||
|
||||
ExampleRequest = new GetBooksLiteRequest(
|
||||
LibraryId: Guid.NewGuid(),
|
||||
CurrentPage: 1,
|
||||
PerPage: 48,
|
||||
PerPage: 10,
|
||||
SearchTerm: "fellowship",
|
||||
FilterAlphaKey: "f",
|
||||
ShouldIgnoreThePrefixForAlphaPicker: true,
|
||||
@@ -36,7 +35,6 @@ public class GetBooksLiteEndpointSummary : Summary<GetBooksLiteEndpoint, GetBook
|
||||
SortOrder: SortOrder.Ascending
|
||||
);
|
||||
|
||||
RequestParam(r => r.LibraryId, "The Id of the media library whose books are retrieved. Required.");
|
||||
RequestParam(r => r.CurrentPage, "The page of results to retrieve. Optional.");
|
||||
RequestParam(r => r.PerPage, "The maximum number of books to retrieve per page. Optional.");
|
||||
RequestParam(r => r.SearchTerm, "The search term used to filter results. Optional.");
|
||||
@@ -45,6 +43,12 @@ public class GetBooksLiteEndpointSummary : Summary<GetBooksLiteEndpoint, GetBook
|
||||
RequestParam(r => r.SortBy, "The name of the field by which to sort the results. Optional.");
|
||||
RequestParam(r => r.SortOrder, "The direction in which to sort the results. Optional.");
|
||||
|
||||
ResponseParam<PaginatedResponse<BookLiteResponse>>(r => r.Data, "The lightweight book details on the current page.");
|
||||
ResponseParam<PaginatedResponse<BookLiteResponse>>(r => r.CurrentPage, "The current page number.");
|
||||
ResponseParam<PaginatedResponse<BookLiteResponse>>(r => r.PerPage, "The number of books retrieved per page.");
|
||||
ResponseParam<PaginatedResponse<BookLiteResponse>>(r => r.Count, "The total number of books matching the request.");
|
||||
ResponseParam<PaginatedResponse<BookLiteResponse>>(r => r.NumberOfPages, "The total number of pages.");
|
||||
|
||||
Response(200, "The paginated list of lightweight book details is returned.",
|
||||
example: new PaginatedResponse<BookLiteResponse>
|
||||
{
|
||||
@@ -77,16 +81,16 @@ public class GetBooksLiteEndpointSummary : Summary<GetBooksLiteEndpoint, GetBook
|
||||
type = "https://tools.ietf.org/html/rfc7235#section-3.1",
|
||||
status = 401,
|
||||
title = "Unauthorized",
|
||||
detail = "You are not authorized",
|
||||
instance = "/api/v1/books/lite"
|
||||
detail = "Authentication failed",
|
||||
instance = $"/api/v1/libraries/{Guid.NewGuid()}/books/lite"
|
||||
},
|
||||
new
|
||||
{
|
||||
type = "https://tools.ietf.org/html/rfc7235#section-3.1",
|
||||
status = 401,
|
||||
title = "Unauthorized",
|
||||
detail = "Invalid token: The token expired at '01/01/2024 01:00:00'",
|
||||
instance = "/api/v1/books/lite"
|
||||
detail = "The token has expired",
|
||||
instance = $"/api/v1/libraries/{Guid.NewGuid()}/books/lite"
|
||||
},
|
||||
new
|
||||
{
|
||||
@@ -94,11 +98,23 @@ public class GetBooksLiteEndpointSummary : Summary<GetBooksLiteEndpoint, GetBook
|
||||
status = 401,
|
||||
title = "Unauthorized",
|
||||
detail = "The token is invalid",
|
||||
instance = "/api/v1/books/lite"
|
||||
instance = $"/api/v1/libraries/{Guid.NewGuid()}/books/lite"
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
Response(403, "The request failed because the user making the request is not an Admin, or the owner of the media library.", "application/problem+json",
|
||||
example: new
|
||||
{
|
||||
type = "https://tools.ietf.org/html/rfc9110#section-15.5.4",
|
||||
title = "General.Unauthorized",
|
||||
status = 403,
|
||||
detail = "NotAuthorized",
|
||||
instance = $"/api/v1/libraries/{Guid.NewGuid()}/books/lite",
|
||||
traceId = "00-a712bbf99ca8ab485f86a762ae5ae74d-b3a2eb78813b0a5d-00"
|
||||
}
|
||||
);
|
||||
|
||||
Response(422, "The request did not pass validation checks.", "application/problem+json",
|
||||
example: new
|
||||
{
|
||||
@@ -106,7 +122,7 @@ public class GetBooksLiteEndpointSummary : Summary<GetBooksLiteEndpoint, GetBook
|
||||
title = "General.Validation",
|
||||
status = 422,
|
||||
detail = "OneOrMoreValidationErrorsOccurred",
|
||||
instance = "/api/v1/books/lite",
|
||||
instance = $"/api/v1/libraries/{Guid.NewGuid()}/books/lite",
|
||||
errors = new Dictionary<string, string[]>
|
||||
{
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user