mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 17:11:10 +00:00
Refactors the album slice across the stack
This commit is contained in:
1 parent
aa097ecc98
commit
d4cc3c1f8d
37 files changed
+600
-305
No files matched your search
+10
-7
@@ -1,8 +1,6 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.CQRS;
|
||||
using Lumina.Application.Common.Mapping.MediaLibrary.AudioLibrary.MusicLibrary.Albums;
|
||||
using Lumina.Application.Core.MediaLibrary.AudioLibrary.MusicLibrary.Albums.Commands.DeleteAlbum;
|
||||
using Lumina.Contracts.Requests.MediaLibrary.AudioLibrary.MusicLibrary.Albums;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Presentation.Api.Common.Routes.Library.AudioLibrary.MusicLibrary;
|
||||
using Lumina.Presentation.Api.Core.Endpoints.Common;
|
||||
@@ -14,9 +12,9 @@ using System.Threading.Tasks;
|
||||
namespace Lumina.Presentation.Api.Core.Endpoints.Library.AudioLibrary.MusicLibrary.Albums.DeleteAlbum;
|
||||
|
||||
/// <summary>
|
||||
/// API endpoint for the <c>/artists/{artistId}/albums/{albumId}</c> route.
|
||||
/// API endpoint for the <c>/libraries/{libraryId}/artists/{artistId}/albums/{albumId}</c> route.
|
||||
/// </summary>
|
||||
public class DeleteAlbumEndpoint : BaseEndpoint<DeleteAlbumRequest, IResult>
|
||||
public class DeleteAlbumEndpoint : BaseEndpoint<FastEndpoints.EmptyRequest, IResult>
|
||||
{
|
||||
private readonly ICommandHandler<DeleteAlbumCommand, Result<Deleted>> _deleteAlbumCommandHandler;
|
||||
|
||||
@@ -43,11 +41,16 @@ public class DeleteAlbumEndpoint : BaseEndpoint<DeleteAlbumRequest, IResult>
|
||||
/// <summary>
|
||||
/// Deletes an album by Id.
|
||||
/// </summary>
|
||||
/// <param name="request">The request containing the id of the album to be deleted.</param>
|
||||
/// <param name="request">The request object.</param>
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
public override async Task<IResult> ExecuteAsync(DeleteAlbumRequest request, CancellationToken cancellationToken)
|
||||
public override async Task<IResult> ExecuteAsync(FastEndpoints.EmptyRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
Result<Deleted> result = await _deleteAlbumCommandHandler.HandleAsync(request.ToCommand(), cancellationToken).ConfigureAwait(false);
|
||||
// Take unique identifiers from the route.
|
||||
string? libraryId = HttpContext.Request.RouteValues["libraryId"]?.ToString();
|
||||
string? artistId = HttpContext.Request.RouteValues["artistId"]?.ToString();
|
||||
string? albumId = HttpContext.Request.RouteValues["albumId"]?.ToString();
|
||||
Result<Deleted> result = await _deleteAlbumCommandHandler
|
||||
.HandleAsync(new DeleteAlbumCommand(libraryId, artistId, albumId), cancellationToken).ConfigureAwait(false);
|
||||
return result.Match(success => TypedResults.Ok(success), Problem);
|
||||
}
|
||||
}
|
||||
+59
-33
@@ -1,6 +1,5 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using FastEndpoints;
|
||||
using Lumina.Contracts.Requests.MediaLibrary.AudioLibrary.MusicLibrary.Albums;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
@@ -12,7 +11,7 @@ namespace Lumina.Presentation.Api.Core.Endpoints.Library.AudioLibrary.MusicLibra
|
||||
/// Class used for providing a textual description for the <see cref="DeleteAlbumEndpoint"/> API endpoint, for OpenAPI.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class DeleteAlbumEndpointSummary : Summary<DeleteAlbumEndpoint, DeleteAlbumRequest>
|
||||
public class DeleteAlbumEndpointSummary : Summary<DeleteAlbumEndpoint, EmptyRequest>
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="DeleteAlbumEndpointSummary"/> class.
|
||||
@@ -20,15 +19,7 @@ public class DeleteAlbumEndpointSummary : Summary<DeleteAlbumEndpoint, DeleteAlb
|
||||
public DeleteAlbumEndpointSummary()
|
||||
{
|
||||
Summary = "Deletes an existing album.";
|
||||
Description = "Deletes the album identified by the request, together with its tracks. The album is deleted by an Admin, who can delete the albums of all libraries, or by the owner of the library of the album.";
|
||||
|
||||
ExampleRequest = new DeleteAlbumRequest(
|
||||
ArtistId: Guid.NewGuid(),
|
||||
AlbumId: Guid.NewGuid()
|
||||
);
|
||||
|
||||
RequestParam(r => r.ArtistId, "The unique identifier of the artist the album belongs to, taken from the route.");
|
||||
RequestParam(r => r.AlbumId, "The Id of the album to delete, taken from the route. Required.");
|
||||
Description = "Deletes the album identified by the path, together with its tracks. An artist must always keep at least one album. The album is deleted by an Admin, who can delete the albums of all libraries, or by the owner of the library of the album.";
|
||||
|
||||
Response(200, "The album was successfully deleted.");
|
||||
|
||||
@@ -40,16 +31,16 @@ public class DeleteAlbumEndpointSummary : Summary<DeleteAlbumEndpoint, DeleteAlb
|
||||
type = "https://tools.ietf.org/html/rfc7235#section-3.1",
|
||||
status = 401,
|
||||
title = "Unauthorized",
|
||||
detail = "You are not authorized",
|
||||
instance = "/api/v1/libraries/{libraryId}/artists/{artistId}/albums/{albumId}"
|
||||
detail = "Authentication failed",
|
||||
instance = $"/api/v1/libraries/{Guid.NewGuid()}/artists/{Guid.NewGuid()}/albums/{Guid.NewGuid()}"
|
||||
},
|
||||
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/libraries/{libraryId}/artists/{artistId}/albums/{albumId}"
|
||||
detail = "The token has expired",
|
||||
instance = $"/api/v1/libraries/{Guid.NewGuid()}/artists/{Guid.NewGuid()}/albums/{Guid.NewGuid()}"
|
||||
},
|
||||
new
|
||||
{
|
||||
@@ -57,32 +48,65 @@ public class DeleteAlbumEndpointSummary : Summary<DeleteAlbumEndpoint, DeleteAlb
|
||||
status = 401,
|
||||
title = "Unauthorized",
|
||||
detail = "The token is invalid",
|
||||
instance = "/api/v1/libraries/{libraryId}/artists/{artistId}/albums/{albumId}"
|
||||
instance = $"/api/v1/libraries/{Guid.NewGuid()}/artists/{Guid.NewGuid()}/albums/{Guid.NewGuid()}"
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
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
|
||||
Response(403, "The request failed because the user making the request is not an Admin or the owner of the media library, or because deleting the album would leave its artist without any albums.", "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/{libraryId}/artists/{artistId}/albums/{albumId}",
|
||||
traceId = "00-a712bbf99ca8ab485f86a762ae5ae74d-b3a2eb78813b0a5d-00"
|
||||
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()}/artists/{Guid.NewGuid()}/albums/{Guid.NewGuid()}",
|
||||
traceId = "00-a712bbf99ca8ab485f86a762ae5ae74d-b3a2eb78813b0a5d-00"
|
||||
},
|
||||
new
|
||||
{
|
||||
type = "https://tools.ietf.org/html/rfc9110#section-15.5.4",
|
||||
title = "General.Forbidden",
|
||||
status = 403,
|
||||
detail = "ArtistMustHaveAtLeastOneAlbum",
|
||||
instance = $"/api/v1/libraries/{Guid.NewGuid()}/artists/{Guid.NewGuid()}/albums/{Guid.NewGuid()}",
|
||||
traceId = "00-a712bbf99ca8ab485f86a762ae5ae74d-b3a2eb78813b0a5d-00"
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
Response(404, "The request failed because the requested album does not exist.", "application/problem+json",
|
||||
example: new
|
||||
Response(404, "The request failed because the requested artist, album, or their media library does not exist.", "application/problem+json",
|
||||
example: new[]
|
||||
{
|
||||
type = "https://tools.ietf.org/html/rfc9110#section-15.5.5",
|
||||
title = "General.NotFound",
|
||||
status = 404,
|
||||
detail = "AlbumNotFound",
|
||||
instance = "/api/v1/libraries/{libraryId}/artists/{artistId}/albums/{albumId}",
|
||||
traceId = "00-57d15dadd702dbd4aeb5dc9b7cee68ee-9330237dbb2ce0e5-00"
|
||||
new
|
||||
{
|
||||
type = "https://tools.ietf.org/html/rfc9110#section-15.5.5",
|
||||
title = "General.NotFound",
|
||||
status = 404,
|
||||
detail = "ArtistNotFound",
|
||||
instance = $"/api/v1/libraries/{Guid.NewGuid()}/artists/{Guid.NewGuid()}/albums/{Guid.NewGuid()}",
|
||||
traceId = "00-57d15dadd702dbd4aeb5dc9b7cee68ee-9330237dbb2ce0e5-00"
|
||||
},
|
||||
new
|
||||
{
|
||||
type = "https://tools.ietf.org/html/rfc9110#section-15.5.5",
|
||||
title = "General.NotFound",
|
||||
status = 404,
|
||||
detail = "AlbumNotFound",
|
||||
instance = $"/api/v1/libraries/{Guid.NewGuid()}/artists/{Guid.NewGuid()}/albums/{Guid.NewGuid()}",
|
||||
traceId = "00-57d15dadd702dbd4aeb5dc9b7cee68ee-9330237dbb2ce0e5-00"
|
||||
},
|
||||
new
|
||||
{
|
||||
type = "https://tools.ietf.org/html/rfc9110#section-15.5.5",
|
||||
title = "General.NotFound",
|
||||
status = 404,
|
||||
detail = "LibraryNotFound",
|
||||
instance = $"/api/v1/libraries/{Guid.NewGuid()}/artists/{Guid.NewGuid()}/albums/{Guid.NewGuid()}",
|
||||
traceId = "00-57d15dadd702dbd4aeb5dc9b7cee68ee-9330237dbb2ce0e5-00"
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
@@ -93,12 +117,14 @@ public class DeleteAlbumEndpointSummary : Summary<DeleteAlbumEndpoint, DeleteAlb
|
||||
title = "General.Validation",
|
||||
status = 422,
|
||||
detail = "OneOrMoreValidationErrorsOccurred",
|
||||
instance = "/api/v1/libraries/{libraryId}/artists/{artistId}/albums/{albumId}",
|
||||
instance = $"/api/v1/libraries/{Guid.NewGuid()}/artists/{Guid.NewGuid()}/albums/{Guid.NewGuid()}",
|
||||
errors = new Dictionary<string, string[]>
|
||||
{
|
||||
{
|
||||
"General.Validation", new[]
|
||||
{
|
||||
"LibraryIdCannotBeEmpty",
|
||||
"ArtistIdCannotBeEmpty",
|
||||
"AlbumIdCannotBeEmpty"
|
||||
}
|
||||
}
|
||||
|
||||
+9
-6
@@ -1,9 +1,7 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using FastEndpoints;
|
||||
using Lumina.Application.Common.CQRS;
|
||||
using Lumina.Application.Common.Mapping.MediaLibrary.AudioLibrary.MusicLibrary.Albums;
|
||||
using Lumina.Application.Core.MediaLibrary.AudioLibrary.MusicLibrary.Albums.Queries.GetAlbum;
|
||||
using Lumina.Contracts.Requests.MediaLibrary.AudioLibrary.MusicLibrary.Albums;
|
||||
using Lumina.Contracts.Responses.MediaLibrary.AudioLibrary.MusicLibrary.Albums;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Presentation.Api.Common.Routes.Library.AudioLibrary.MusicLibrary;
|
||||
@@ -18,7 +16,7 @@ namespace Lumina.Presentation.Api.Core.Endpoints.Library.AudioLibrary.MusicLibra
|
||||
/// <summary>
|
||||
/// API endpoint for the <c>/artists/{artistId}/albums/{albumId}</c> route.
|
||||
/// </summary>
|
||||
public class GetAlbumEndpoint : BaseEndpoint<GetAlbumRequest, IResult>
|
||||
public class GetAlbumEndpoint : BaseEndpoint<FastEndpoints.EmptyRequest, IResult>
|
||||
{
|
||||
private readonly IQueryHandler<GetAlbumQuery, Result<AlbumResponse>> _getAlbumQueryHandler;
|
||||
|
||||
@@ -45,11 +43,16 @@ public class GetAlbumEndpoint : BaseEndpoint<GetAlbumRequest, IResult>
|
||||
/// <summary>
|
||||
/// Gets an album by Id.
|
||||
/// </summary>
|
||||
/// <param name="request">The request containing the id of the album to be retrieved.</param>
|
||||
/// <param name="request">The request object.</param>
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
public override async Task<IResult> ExecuteAsync(GetAlbumRequest request, CancellationToken cancellationToken)
|
||||
public override async Task<IResult> ExecuteAsync(FastEndpoints.EmptyRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
Result<AlbumResponse> result = await _getAlbumQueryHandler.HandleAsync(request.ToQuery(), cancellationToken).ConfigureAwait(false);
|
||||
// Take unique identifiers from the route.
|
||||
string? libraryId = HttpContext.Request.RouteValues["libraryId"]?.ToString();
|
||||
string? artistId = HttpContext.Request.RouteValues["artistId"]?.ToString();
|
||||
string? albumId = HttpContext.Request.RouteValues["albumId"]?.ToString();
|
||||
GetAlbumQuery query = new(libraryId, artistId, albumId);
|
||||
Result<AlbumResponse> result = await _getAlbumQueryHandler.HandleAsync(query, cancellationToken).ConfigureAwait(false);
|
||||
return result.Match(success => TypedResults.Ok(success), Problem);
|
||||
}
|
||||
}
|
||||
+8
-17
@@ -4,7 +4,6 @@ using Lumina.Contracts.DTO.Common;
|
||||
using Lumina.Contracts.DTO.MediaContributors;
|
||||
using Lumina.Contracts.DTO.MediaLibrary.AudioLibrary;
|
||||
using Lumina.Contracts.DTO.MediaLibrary.AudioLibrary.MusicLibrary;
|
||||
using Lumina.Contracts.Requests.MediaLibrary.AudioLibrary.MusicLibrary.Albums;
|
||||
using Lumina.Contracts.Responses.MediaLibrary.AudioLibrary.MusicLibrary.Albums;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.AudioLibrary;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.Common;
|
||||
@@ -20,7 +19,7 @@ namespace Lumina.Presentation.Api.Core.Endpoints.Library.AudioLibrary.MusicLibra
|
||||
/// Class used for providing a textual description for the <see cref="GetAlbumEndpoint"/> API endpoint, for OpenAPI.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class GetAlbumEndpointSummary : Summary<GetAlbumEndpoint, GetAlbumRequest>
|
||||
public class GetAlbumEndpointSummary : Summary<GetAlbumEndpoint, EmptyRequest>
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="GetAlbumEndpointSummary"/> class.
|
||||
@@ -28,15 +27,7 @@ public class GetAlbumEndpointSummary : Summary<GetAlbumEndpoint, GetAlbumRequest
|
||||
public GetAlbumEndpointSummary()
|
||||
{
|
||||
Summary = "Gets an album by its Id.";
|
||||
Description = "Returns the full details of the album identified by the request. The album is returned to an Admin, who can see the albums of all libraries, or to the owner of the library of the album.";
|
||||
|
||||
ExampleRequest = new GetAlbumRequest(
|
||||
ArtistId: Guid.NewGuid(),
|
||||
AlbumId: Guid.NewGuid()
|
||||
);
|
||||
|
||||
RequestParam(r => r.ArtistId, "The unique identifier of the artist the album belongs to, taken from the route.");
|
||||
RequestParam(r => r.AlbumId, "The Id of the album to get. Required.");
|
||||
Description = "Returns the full details of the album identified by the route. The album is returned to an Admin, who can see the albums of all libraries, or to the owner of the library of the album.";
|
||||
|
||||
ResponseParam<AlbumResponse>(r => r.Id, "The Id of the album.");
|
||||
ResponseParam<AlbumResponse>(r => r.ArtistId, "The Id of the artist the album belongs to.");
|
||||
@@ -159,7 +150,7 @@ public class GetAlbumEndpointSummary : Summary<GetAlbumEndpoint, GetAlbumRequest
|
||||
status = 401,
|
||||
title = "Unauthorized",
|
||||
detail = "You are not authorized",
|
||||
instance = "/api/v1/libraries/{libraryId}/artists/{artistId}/albums/{albumId}"
|
||||
instance = $"/api/v1/libraries/{Guid.NewGuid()}/artists/{Guid.NewGuid()}/albums/{Guid.NewGuid()}"
|
||||
},
|
||||
new
|
||||
{
|
||||
@@ -167,7 +158,7 @@ public class GetAlbumEndpointSummary : Summary<GetAlbumEndpoint, GetAlbumRequest
|
||||
status = 401,
|
||||
title = "Unauthorized",
|
||||
detail = "Invalid token: The token expired at '01/01/2024 01:00:00'",
|
||||
instance = "/api/v1/libraries/{libraryId}/artists/{artistId}/albums/{albumId}"
|
||||
instance = $"/api/v1/libraries/{Guid.NewGuid()}/artists/{Guid.NewGuid()}/albums/{Guid.NewGuid()}"
|
||||
},
|
||||
new
|
||||
{
|
||||
@@ -175,7 +166,7 @@ public class GetAlbumEndpointSummary : Summary<GetAlbumEndpoint, GetAlbumRequest
|
||||
status = 401,
|
||||
title = "Unauthorized",
|
||||
detail = "The token is invalid",
|
||||
instance = "/api/v1/libraries/{libraryId}/artists/{artistId}/albums/{albumId}"
|
||||
instance = $"/api/v1/libraries/{Guid.NewGuid()}/artists/{Guid.NewGuid()}/albums/{Guid.NewGuid()}"
|
||||
}
|
||||
}
|
||||
);
|
||||
@@ -187,7 +178,7 @@ public class GetAlbumEndpointSummary : Summary<GetAlbumEndpoint, GetAlbumRequest
|
||||
title = "General.Unauthorized",
|
||||
status = 403,
|
||||
detail = "NotAuthorized",
|
||||
instance = "/api/v1/libraries/{libraryId}/artists/{artistId}/albums/{albumId}",
|
||||
instance = $"/api/v1/libraries/{Guid.NewGuid()}/artists/{Guid.NewGuid()}/albums/{Guid.NewGuid()}",
|
||||
traceId = "00-a712bbf99ca8ab485f86a762ae5ae74d-b3a2eb78813b0a5d-00"
|
||||
}
|
||||
);
|
||||
@@ -199,7 +190,7 @@ public class GetAlbumEndpointSummary : Summary<GetAlbumEndpoint, GetAlbumRequest
|
||||
title = "General.NotFound",
|
||||
status = 404,
|
||||
detail = "AlbumNotFound",
|
||||
instance = "/api/v1/libraries/{libraryId}/artists/{artistId}/albums/{albumId}",
|
||||
instance = $"/api/v1/libraries/{Guid.NewGuid()}/artists/{Guid.NewGuid()}/albums/{Guid.NewGuid()}",
|
||||
traceId = "00-57d15dadd702dbd4aeb5dc9b7cee68ee-9330237dbb2ce0e5-00"
|
||||
}
|
||||
);
|
||||
@@ -211,7 +202,7 @@ public class GetAlbumEndpointSummary : Summary<GetAlbumEndpoint, GetAlbumRequest
|
||||
title = "General.Validation",
|
||||
status = 422,
|
||||
detail = "OneOrMoreValidationErrorsOccurred",
|
||||
instance = "/api/v1/libraries/{libraryId}/artists/{artistId}/albums/{albumId}",
|
||||
instance = $"/api/v1/libraries/{Guid.NewGuid()}/artists/{Guid.NewGuid()}/albums/{Guid.NewGuid()}",
|
||||
errors = new Dictionary<string, string[]>
|
||||
{
|
||||
{
|
||||
|
||||
+10
-7
@@ -1,9 +1,7 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using FastEndpoints;
|
||||
using Lumina.Application.Common.CQRS;
|
||||
using Lumina.Application.Common.Mapping.MediaLibrary.AudioLibrary.MusicLibrary.Albums;
|
||||
using Lumina.Application.Core.MediaLibrary.AudioLibrary.MusicLibrary.Albums.Queries.GetAlbumTracks;
|
||||
using Lumina.Contracts.Requests.MediaLibrary.AudioLibrary.MusicLibrary.Albums;
|
||||
using Lumina.Contracts.Responses.MediaLibrary.AudioLibrary.MusicLibrary.Tracks;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Presentation.Api.Common.Routes.Library.AudioLibrary.MusicLibrary;
|
||||
@@ -19,7 +17,7 @@ namespace Lumina.Presentation.Api.Core.Endpoints.Library.AudioLibrary.MusicLibra
|
||||
/// <summary>
|
||||
/// API endpoint for the <c>/artists/{artistId}/albums/{albumId}/tracks</c> route.
|
||||
/// </summary>
|
||||
public class GetAlbumTracksEndpoint : BaseEndpoint<GetAlbumTracksRequest, IResult>
|
||||
public class GetAlbumTracksEndpoint : BaseEndpoint<FastEndpoints.EmptyRequest, IResult>
|
||||
{
|
||||
private readonly IQueryHandler<GetAlbumTracksQuery, Result<IReadOnlyList<TrackResponse>>> _getAlbumTracksQueryHandler;
|
||||
|
||||
@@ -44,13 +42,18 @@ public class GetAlbumTracksEndpoint : BaseEndpoint<GetAlbumTracksRequest, IResul
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the list of all the tracks of the album identified by <paramref name="request"/>.
|
||||
/// Gets the list of all the tracks of the album identified by the route.
|
||||
/// </summary>
|
||||
/// <param name="request">The request containing the id of the album whose tracks are retrieved.</param>
|
||||
/// <param name="request">The request object.</param>
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
public override async Task<IResult> ExecuteAsync(GetAlbumTracksRequest request, CancellationToken cancellationToken)
|
||||
public override async Task<IResult> ExecuteAsync(FastEndpoints.EmptyRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
Result<IReadOnlyList<TrackResponse>> result = await _getAlbumTracksQueryHandler.HandleAsync(request.ToQuery(), cancellationToken).ConfigureAwait(false);
|
||||
// Take unique identifiers from the route.
|
||||
string? libraryId = HttpContext.Request.RouteValues["libraryId"]?.ToString();
|
||||
string? artistId = HttpContext.Request.RouteValues["artistId"]?.ToString();
|
||||
string? albumId = HttpContext.Request.RouteValues["albumId"]?.ToString();
|
||||
GetAlbumTracksQuery query = new(libraryId, artistId, albumId);
|
||||
Result<IReadOnlyList<TrackResponse>> result = await _getAlbumTracksQueryHandler.HandleAsync(query, cancellationToken).ConfigureAwait(false);
|
||||
return result.Match(success => TypedResults.Ok(success), Problem);
|
||||
}
|
||||
}
|
||||
+8
-17
@@ -4,7 +4,6 @@ using Lumina.Contracts.DTO.Common;
|
||||
using Lumina.Contracts.DTO.MediaContributors;
|
||||
using Lumina.Contracts.DTO.MediaLibrary.AudioLibrary;
|
||||
using Lumina.Contracts.DTO.MediaLibrary.AudioLibrary.MusicLibrary;
|
||||
using Lumina.Contracts.Requests.MediaLibrary.AudioLibrary.MusicLibrary.Albums;
|
||||
using Lumina.Contracts.Responses.MediaLibrary.AudioLibrary.MusicLibrary.Tracks;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.AudioLibrary;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.Common;
|
||||
@@ -20,7 +19,7 @@ namespace Lumina.Presentation.Api.Core.Endpoints.Library.AudioLibrary.MusicLibra
|
||||
/// Class used for providing a textual description for the <see cref="GetAlbumTracksEndpoint"/> API endpoint, for OpenAPI.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class GetAlbumTracksEndpointSummary : Summary<GetAlbumTracksEndpoint, GetAlbumTracksRequest>
|
||||
public class GetAlbumTracksEndpointSummary : Summary<GetAlbumTracksEndpoint, EmptyRequest>
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="GetAlbumTracksEndpointSummary"/> class.
|
||||
@@ -28,15 +27,7 @@ public class GetAlbumTracksEndpointSummary : Summary<GetAlbumTracksEndpoint, Get
|
||||
public GetAlbumTracksEndpointSummary()
|
||||
{
|
||||
Summary = "Retrieves the list of tracks of an album.";
|
||||
Description = "Returns the full details of the tracks of the album identified by the request. The list is returned to an Admin, who can see the tracks of the albums of all libraries, or to the owner of the library of the album.";
|
||||
|
||||
ExampleRequest = new GetAlbumTracksRequest(
|
||||
ArtistId: Guid.NewGuid(),
|
||||
AlbumId: Guid.NewGuid()
|
||||
);
|
||||
|
||||
RequestParam(r => r.ArtistId, "The unique identifier of the artist the album belongs to, taken from the route.");
|
||||
RequestParam(r => r.AlbumId, "The Id of the album whose tracks are retrieved, taken from the route. Required.");
|
||||
Description = "Returns the full details of the tracks of the album identified by the route. The list is returned to an Admin, who can see the tracks of the albums of all libraries, or to the owner of the library of the album.";
|
||||
|
||||
ResponseParam<TrackResponse>(r => r.Id, "The Id of the track.");
|
||||
ResponseParam<TrackResponse>(r => r.AlbumId, "The Id of the album the track belongs to.");
|
||||
@@ -266,7 +257,7 @@ public class GetAlbumTracksEndpointSummary : Summary<GetAlbumTracksEndpoint, Get
|
||||
status = 401,
|
||||
title = "Unauthorized",
|
||||
detail = "You are not authorized",
|
||||
instance = "/api/v1/libraries/{libraryId}/artists/{artistId}/albums/{albumId}/tracks"
|
||||
instance = $"/api/v1/libraries/{Guid.NewGuid()}/artists/{Guid.NewGuid()}/albums/{Guid.NewGuid()}/tracks"
|
||||
},
|
||||
new
|
||||
{
|
||||
@@ -274,7 +265,7 @@ public class GetAlbumTracksEndpointSummary : Summary<GetAlbumTracksEndpoint, Get
|
||||
status = 401,
|
||||
title = "Unauthorized",
|
||||
detail = "Invalid token: The token expired at '01/01/2024 01:00:00'",
|
||||
instance = "/api/v1/libraries/{libraryId}/artists/{artistId}/albums/{albumId}/tracks"
|
||||
instance = $"/api/v1/libraries/{Guid.NewGuid()}/artists/{Guid.NewGuid()}/albums/{Guid.NewGuid()}/tracks"
|
||||
},
|
||||
new
|
||||
{
|
||||
@@ -282,7 +273,7 @@ public class GetAlbumTracksEndpointSummary : Summary<GetAlbumTracksEndpoint, Get
|
||||
status = 401,
|
||||
title = "Unauthorized",
|
||||
detail = "The token is invalid",
|
||||
instance = "/api/v1/libraries/{libraryId}/artists/{artistId}/albums/{albumId}/tracks"
|
||||
instance = $"/api/v1/libraries/{Guid.NewGuid()}/artists/{Guid.NewGuid()}/albums/{Guid.NewGuid()}/tracks"
|
||||
}
|
||||
}
|
||||
);
|
||||
@@ -294,7 +285,7 @@ public class GetAlbumTracksEndpointSummary : Summary<GetAlbumTracksEndpoint, Get
|
||||
title = "General.Unauthorized",
|
||||
status = 403,
|
||||
detail = "NotAuthorized",
|
||||
instance = "/api/v1/libraries/{libraryId}/artists/{artistId}/albums/{albumId}/tracks",
|
||||
instance = $"/api/v1/libraries/{Guid.NewGuid()}/artists/{Guid.NewGuid()}/albums/{Guid.NewGuid()}/tracks",
|
||||
traceId = "00-a712bbf99ca8ab485f86a762ae5ae74d-b3a2eb78813b0a5d-00"
|
||||
}
|
||||
);
|
||||
@@ -306,7 +297,7 @@ public class GetAlbumTracksEndpointSummary : Summary<GetAlbumTracksEndpoint, Get
|
||||
title = "General.NotFound",
|
||||
status = 404,
|
||||
detail = "AlbumNotFound",
|
||||
instance = "/api/v1/libraries/{libraryId}/artists/{artistId}/albums/{albumId}/tracks",
|
||||
instance = $"/api/v1/libraries/{Guid.NewGuid()}/artists/{Guid.NewGuid()}/albums/{Guid.NewGuid()}/tracks",
|
||||
traceId = "00-57d15dadd702dbd4aeb5dc9b7cee68ee-9330237dbb2ce0e5-00"
|
||||
}
|
||||
);
|
||||
@@ -318,7 +309,7 @@ public class GetAlbumTracksEndpointSummary : Summary<GetAlbumTracksEndpoint, Get
|
||||
title = "General.Validation",
|
||||
status = 422,
|
||||
detail = "OneOrMoreValidationErrorsOccurred",
|
||||
instance = "/api/v1/libraries/{libraryId}/artists/{artistId}/albums/{albumId}/tracks",
|
||||
instance = $"/api/v1/libraries/{Guid.NewGuid()}/artists/{Guid.NewGuid()}/albums/{Guid.NewGuid()}/tracks",
|
||||
errors = new Dictionary<string, string[]>
|
||||
{
|
||||
{
|
||||
|
||||
+7
-3
@@ -44,13 +44,17 @@ public class GetAlbumTracksLiteEndpoint : BaseEndpoint<GetAlbumTracksLiteRequest
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the lightweight read models of all the tracks of the album identified by <paramref name="request"/>.
|
||||
/// Gets the lightweight read models of all the tracks of the album identified by the route.
|
||||
/// </summary>
|
||||
/// <param name="request">The request containing the id of the album whose tracks are retrieved.</param>
|
||||
/// <param name="request">The request containing the pagination options of the tracks to be retrieved.</param>
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
public override async Task<IResult> ExecuteAsync(GetAlbumTracksLiteRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
Result<PaginatedResponse<TrackLiteResponse>> result = await _getAlbumTracksLiteQueryHandler.HandleAsync(request.ToQuery(), cancellationToken).ConfigureAwait(false);
|
||||
// Take unique identifiers from the route.
|
||||
string? libraryId = HttpContext.Request.RouteValues["libraryId"]?.ToString();
|
||||
string? artistId = HttpContext.Request.RouteValues["artistId"]?.ToString();
|
||||
string? albumId = HttpContext.Request.RouteValues["albumId"]?.ToString();
|
||||
Result<PaginatedResponse<TrackLiteResponse>> result = await _getAlbumTracksLiteQueryHandler.HandleAsync(request.ToQuery(libraryId, artistId, albumId), cancellationToken).ConfigureAwait(false);
|
||||
return result.Match(success => TypedResults.Ok(success), Problem);
|
||||
}
|
||||
}
|
||||
+6
-10
@@ -25,14 +25,10 @@ public class GetAlbumTracksLiteEndpointSummary : Summary<GetAlbumTracksLiteEndpo
|
||||
Description = "Returns the lightweight read models of the tracks of the album identified by its Id, projecting only the fields needed to display the songs of an album, without loading the full track entities and their related data. The page is returned to an Admin, who can see the tracks of the albums of all libraries, or to the owner of the library of the album.";
|
||||
|
||||
ExampleRequest = new GetAlbumTracksLiteRequest(
|
||||
ArtistId: Guid.NewGuid(),
|
||||
AlbumId: Guid.NewGuid(),
|
||||
CurrentPage: 1,
|
||||
PerPage: 48
|
||||
);
|
||||
|
||||
RequestParam(r => r.ArtistId, "The unique identifier of the artist the album belongs to, taken from the route.");
|
||||
RequestParam(r => r.AlbumId, "The Id of the album whose tracks are retrieved. Required.");
|
||||
RequestParam(r => r.CurrentPage, "The page of results to retrieve. Optional.");
|
||||
RequestParam(r => r.PerPage, "The maximum number of tracks to retrieve per page. Optional.");
|
||||
|
||||
@@ -75,7 +71,7 @@ public class GetAlbumTracksLiteEndpointSummary : Summary<GetAlbumTracksLiteEndpo
|
||||
status = 401,
|
||||
title = "Unauthorized",
|
||||
detail = "You are not authorized",
|
||||
instance = "/api/v1/libraries/{libraryId}/artists/{artistId}/albums/{albumId}/tracks/lite"
|
||||
instance = $"/api/v1/libraries/{Guid.NewGuid()}/artists/{Guid.NewGuid()}/albums/{Guid.NewGuid()}/tracks/lite"
|
||||
},
|
||||
new
|
||||
{
|
||||
@@ -83,7 +79,7 @@ public class GetAlbumTracksLiteEndpointSummary : Summary<GetAlbumTracksLiteEndpo
|
||||
status = 401,
|
||||
title = "Unauthorized",
|
||||
detail = "Invalid token: The token expired at '01/01/2024 01:00:00'",
|
||||
instance = "/api/v1/libraries/{libraryId}/artists/{artistId}/albums/{albumId}/tracks/lite"
|
||||
instance = $"/api/v1/libraries/{Guid.NewGuid()}/artists/{Guid.NewGuid()}/albums/{Guid.NewGuid()}/tracks/lite"
|
||||
},
|
||||
new
|
||||
{
|
||||
@@ -91,7 +87,7 @@ public class GetAlbumTracksLiteEndpointSummary : Summary<GetAlbumTracksLiteEndpo
|
||||
status = 401,
|
||||
title = "Unauthorized",
|
||||
detail = "The token is invalid",
|
||||
instance = "/api/v1/libraries/{libraryId}/artists/{artistId}/albums/{albumId}/tracks/lite"
|
||||
instance = $"/api/v1/libraries/{Guid.NewGuid()}/artists/{Guid.NewGuid()}/albums/{Guid.NewGuid()}/tracks/lite"
|
||||
}
|
||||
}
|
||||
);
|
||||
@@ -103,7 +99,7 @@ public class GetAlbumTracksLiteEndpointSummary : Summary<GetAlbumTracksLiteEndpo
|
||||
title = "General.Unauthorized",
|
||||
status = 403,
|
||||
detail = "NotAuthorized",
|
||||
instance = "/api/v1/libraries/{libraryId}/artists/{artistId}/albums/{albumId}/tracks/lite",
|
||||
instance = $"/api/v1/libraries/{Guid.NewGuid()}/artists/{Guid.NewGuid()}/albums/{Guid.NewGuid()}/tracks/lite",
|
||||
traceId = "00-a712bbf99ca8ab485f86a762ae5ae74d-b3a2eb78813b0a5d-00"
|
||||
}
|
||||
);
|
||||
@@ -115,7 +111,7 @@ public class GetAlbumTracksLiteEndpointSummary : Summary<GetAlbumTracksLiteEndpo
|
||||
title = "General.NotFound",
|
||||
status = 404,
|
||||
detail = "AlbumNotFound",
|
||||
instance = "/api/v1/libraries/{libraryId}/artists/{artistId}/albums/{albumId}/tracks/lite",
|
||||
instance = $"/api/v1/libraries/{Guid.NewGuid()}/artists/{Guid.NewGuid()}/albums/{Guid.NewGuid()}/tracks/lite",
|
||||
traceId = "00-57d15dadd702dbd4aeb5dc9b7cee68ee-9330237dbb2ce0e5-00"
|
||||
}
|
||||
);
|
||||
@@ -127,7 +123,7 @@ public class GetAlbumTracksLiteEndpointSummary : Summary<GetAlbumTracksLiteEndpo
|
||||
title = "General.Validation",
|
||||
status = 422,
|
||||
detail = "OneOrMoreValidationErrorsOccurred",
|
||||
instance = "/api/v1/libraries/{libraryId}/artists/{artistId}/albums/{albumId}/tracks/lite",
|
||||
instance = $"/api/v1/libraries/{Guid.NewGuid()}/artists/{Guid.NewGuid()}/albums/{Guid.NewGuid()}/tracks/lite",
|
||||
errors = new Dictionary<string, string[]>
|
||||
{
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user