mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 10:11:10 +00:00
Implements first stage library management system
This commit is contained in:
1 parent
5e0f94cd82
commit
36352ea9e8
291 files changed
+3733
-1384
No files matched your search
@@ -0,0 +1,17 @@
|
||||
namespace Lumina.Presentation.Api.Common.Routes.Library.Management;
|
||||
|
||||
/// <summary>
|
||||
/// Class for the collection of routes defined in this API.
|
||||
/// </summary>
|
||||
public static partial class ApiRoutes
|
||||
{
|
||||
/// <summary>
|
||||
/// Routes for the Libraries route.
|
||||
/// </summary>
|
||||
public static class Libraries
|
||||
{
|
||||
public const string GET_LIBRARY_BY_ID = "/libraries/{id}";
|
||||
public const string GET_LIBRARIES = "/libraries";
|
||||
public const string ADD_LIBRARY = "/libraries";
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
namespace Lumina.Presentation.Api.Common.Routes.WrittenContentLibrary.BookLibrary;
|
||||
namespace Lumina.Presentation.Api.Common.Routes.Library.WrittenContentLibrary.BookLibrary;
|
||||
|
||||
/// <summary>
|
||||
/// Class for the collection of routes defined in this API.
|
||||
+5
-5
@@ -1,10 +1,10 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using ErrorOr;
|
||||
using FastEndpoints;
|
||||
using Lumina.Application.Common.Mapping.WrittenContentLibrary.BookLibrary.Books;
|
||||
using Lumina.Contracts.Requests.WrittenContentLibrary.BookLibrary.Books;
|
||||
using Lumina.Contracts.Responses.WrittenContentLibrary.BookLibrary.Books;
|
||||
using Lumina.Presentation.Api.Common.Routes.WrittenContentLibrary.BookLibrary;
|
||||
using Lumina.Application.Common.Mapping.MediaLibrary.WrittenContentLibrary.BookLibrary.Books;
|
||||
using Lumina.Contracts.Requests.MediaLibrary.WrittenContentLibrary.BookLibrary.Books;
|
||||
using Lumina.Contracts.Responses.MediaLibrary.WrittenContentLibrary.BookLibrary.Books;
|
||||
using Lumina.Presentation.Api.Common.Routes.Library.WrittenContentLibrary.BookLibrary;
|
||||
using Lumina.Presentation.Api.Core.Endpoints.Common;
|
||||
using Mediator;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
@@ -12,7 +12,7 @@ using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Api.Core.Endpoints.WrittenContentLibrary.BookLibrary.Books.AddBook;
|
||||
namespace Lumina.Presentation.Api.Core.Endpoints.Library.WrittenContentLibrary.BookLibrary.Books.AddBook;
|
||||
|
||||
/// <summary>
|
||||
/// API endpoint for the <c>/books</c> route.
|
||||
+7
-6
@@ -1,20 +1,21 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using FastEndpoints;
|
||||
using Lumina.Contracts.Requests.WrittenContentLibrary.BookLibrary.Books;
|
||||
using Lumina.Contracts.Responses.WrittenContentLibrary.BookLibrary.Books;
|
||||
using Lumina.Contracts.Requests.MediaLibrary.WrittenContentLibrary.BookLibrary.Books;
|
||||
using Lumina.Contracts.Responses.MediaLibrary.WrittenContentLibrary.BookLibrary.Books;
|
||||
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Api.Core.Endpoints.WrittenContentLibrary.BookLibrary.Books.AddBook;
|
||||
namespace Lumina.Presentation.Api.Core.Endpoints.Library.WrittenContentLibrary.BookLibrary.Books.AddBook;
|
||||
|
||||
/// <summary>
|
||||
/// Class used for providing a textual description for the <see cref="AddBookEndpoint"/> API endpoint, for Swagger.
|
||||
/// </summary>
|
||||
public class AddBookEndpointSummary : Summary<AddBookEndpoint, AddBookRequest>
|
||||
public class AddLibraryEndpointSummary : Summary<AddBookEndpoint, AddBookRequest>
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="AddBookEndpointSummary"/> class.
|
||||
/// Initializes a new instance of the <see cref="AddLibraryEndpointSummary"/> class.
|
||||
/// </summary>
|
||||
public AddBookEndpointSummary()
|
||||
public AddLibraryEndpointSummary()
|
||||
{
|
||||
Summary = "Adds a new book.";
|
||||
Description = "Creates a new book and returns its details, including the location of the newly created resource.";
|
||||
+4
-4
@@ -1,9 +1,9 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using ErrorOr;
|
||||
using FastEndpoints;
|
||||
using Lumina.Application.Core.WrittenContentLibrary.BooksLibrary.Books.Queries.GetBooks;
|
||||
using Lumina.Contracts.Responses.WrittenContentLibrary.BookLibrary.Books;
|
||||
using Lumina.Presentation.Api.Common.Routes.WrittenContentLibrary.BookLibrary;
|
||||
using Lumina.Application.Core.MediaLibrary.WrittenContentLibrary.BooksLibrary.Books.Queries.GetBooks;
|
||||
using Lumina.Contracts.Responses.MediaLibrary.WrittenContentLibrary.BookLibrary.Books;
|
||||
using Lumina.Presentation.Api.Common.Routes.Library.WrittenContentLibrary.BookLibrary;
|
||||
using Lumina.Presentation.Api.Core.Endpoints.Common;
|
||||
using Mediator;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
@@ -12,7 +12,7 @@ using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Api.Core.Endpoints.WrittenContentLibrary.BookLibrary.Books.GetBooks;
|
||||
namespace Lumina.Presentation.Api.Core.Endpoints.Library.WrittenContentLibrary.BookLibrary.Books.GetBooks;
|
||||
|
||||
/// <summary>
|
||||
/// API endpoint for the <c>/books</c> route.
|
||||
+2
-2
@@ -1,10 +1,10 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using FastEndpoints;
|
||||
using Lumina.Contracts.Responses.WrittenContentLibrary.BookLibrary.Books;
|
||||
using Lumina.Contracts.Responses.MediaLibrary.WrittenContentLibrary.BookLibrary.Books;
|
||||
using System.Collections.Generic;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Api.Core.Endpoints.WrittenContentLibrary.BookLibrary.Books.GetBooks;
|
||||
namespace Lumina.Presentation.Api.Core.Endpoints.Library.WrittenContentLibrary.BookLibrary.Books.GetBooks;
|
||||
|
||||
/// <summary>
|
||||
/// Class used for providing a textual description for the <see cref="GetBooksEndpoint"/> API endpoint, for Swagger.
|
||||
+3
-6
@@ -1,10 +1,7 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using ErrorOr;
|
||||
using FastEndpoints;
|
||||
using Lumina.Application.Common.Mapping.WrittenContentLibrary.BookLibrary.Books;
|
||||
using Lumina.Contracts.Requests.WrittenContentLibrary.BookLibrary.Books;
|
||||
using Lumina.Domain.Core.Aggregates.WrittenContentLibrary.BookLibraryAggregate;
|
||||
using Lumina.Presentation.Api.Common.Routes.WrittenContentLibrary.BookLibrary;
|
||||
using Lumina.Contracts.Requests.MediaLibrary.WrittenContentLibrary.BookLibrary.Books;
|
||||
using Lumina.Presentation.Api.Common.Routes.Library.WrittenContentLibrary.BookLibrary;
|
||||
using Lumina.Presentation.Api.Core.Endpoints.Common;
|
||||
using Mediator;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
@@ -12,7 +9,7 @@ using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Api.Core.Endpoints.WrittenContentLibrary.BookLibrary.GetBook;
|
||||
namespace Lumina.Presentation.Api.Core.Endpoints.Library.WrittenContentLibrary.BookLibrary.GetBook;
|
||||
|
||||
/// <summary>
|
||||
/// API endpoint for the <c>/books</c> route.
|
||||
+55
@@ -0,0 +1,55 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using ErrorOr;
|
||||
using FastEndpoints;
|
||||
using Lumina.Application.Common.Mapping.MediaLibrary.Management;
|
||||
using Lumina.Contracts.Requests.MediaLibrary.Management;
|
||||
using Lumina.Contracts.Responses.MediaLibrary.Management;
|
||||
using Lumina.Presentation.Api.Common.Routes.Library.Management;
|
||||
using Lumina.Presentation.Api.Core.Endpoints.Common;
|
||||
using Mediator;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Api.Core.Endpoints.Library.WrittenContentLibrary.Management.AddLibrary;
|
||||
|
||||
/// <summary>
|
||||
/// API endpoint for the <c>/library</c> route.
|
||||
/// </summary>
|
||||
public class AddLibraryEndpoint : BaseEndpoint<AddLibraryRequest, IResult>
|
||||
{
|
||||
private readonly ISender _sender;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="AddLibraryEndpoint"/> class.
|
||||
/// </summary>
|
||||
/// <param name="sender">Injected service for mediating commands and queries.</param>
|
||||
public AddLibraryEndpoint(ISender sender)
|
||||
{
|
||||
_sender = sender;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Configures the API endpoint.
|
||||
/// </summary>
|
||||
public override void Configure()
|
||||
{
|
||||
Verbs(Http.POST);
|
||||
Routes(ApiRoutes.Libraries.ADD_LIBRARY);
|
||||
Version(1);
|
||||
AllowAnonymous();
|
||||
DontCatchExceptions();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a media library stored in <paramref name="request"/>.
|
||||
/// </summary>
|
||||
/// <param name="request">The request containing the media library to be added.</param>
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
public override async Task<IResult> ExecuteAsync(AddLibraryRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
ErrorOr<LibraryResponse> result = await _sender.Send(request.ToCommand(), cancellationToken).ConfigureAwait(false);
|
||||
return result.Match(success => TypedResults.Created($"{BaseURL}api/v1{ApiRoutes.Libraries.ADD_LIBRARY}/{result.Value.Id}", result.Value), Problem);
|
||||
}
|
||||
}
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using FastEndpoints;
|
||||
using Lumina.Contracts.Requests.MediaLibrary.Management;
|
||||
using Lumina.Contracts.Responses.MediaLibrary.Management;
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Api.Core.Endpoints.Library.WrittenContentLibrary.Management.AddLibrary;
|
||||
|
||||
/// <summary>
|
||||
/// Class used for providing a textual description for the <see cref="AddLibraryEndpoint"/> API endpoint, for Swagger.
|
||||
/// </summary>
|
||||
public class AddLibraryEndpointSummary : Summary<AddLibraryEndpoint, AddLibraryRequest>
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="AddLibraryEndpointSummary"/> class.
|
||||
/// </summary>
|
||||
public AddLibraryEndpointSummary()
|
||||
{
|
||||
Summary = "Adds a new media library.";
|
||||
Description = "Creates a new media library and returns its details, including the location of the newly created resource.";
|
||||
|
||||
RequestParam(r => r.UserId, "The Id of the user owning the media library.");
|
||||
RequestParam(r => r.Title, "The title of the media library.");
|
||||
RequestParam(r => r.LibraryType, "The type of the media library.");
|
||||
RequestParam(r => r.ContentLocations, ">The file system paths of the directories where the media library elements are located.");
|
||||
|
||||
ResponseParam<LibraryResponse>(r => r.Id, "The unique identifier of the entity.");
|
||||
ResponseParam<LibraryResponse>(r => r.UserId, "The Id of the user owning the media library.");
|
||||
ResponseParam<LibraryResponse>(r => r.Title, "The title of the media library.");
|
||||
ResponseParam<LibraryResponse>(r => r.LibraryType, "The type of the media library.");
|
||||
ResponseParam<LibraryResponse>(r => r.ContentLocations, "The file system paths of the directories where the media library elements are located.");
|
||||
ResponseParam<LibraryResponse>(r => r.Created, "The date and time when the entity was created.");
|
||||
ResponseParam<LibraryResponse>(r => r.Updated, "The date and time when the entity was last updated.");
|
||||
Response<LibraryResponse>(201, "The media library was successfully created.", "The location of the created resource is provided in the Location header.");
|
||||
Response<ProblemDetails>(422, "The request did not pass validation checks.", "application/problem+json");
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user