Implement collection suggestions and bulk show addition features
Added new API endpoints for suggesting collections based on existing shows and for bulk adding shows to collections. Enhanced the backend with necessary logic and DTOs to support these features. Updated the frontend to include new components for displaying collection suggestions and managing bulk additions, improving the user experience for collection management. Localization updates were made to support these new features in both English and Russian.
This commit is contained in:
@@ -2,6 +2,7 @@ using LiteCqrs;
|
||||
using TeleWave.Api.Common;
|
||||
using TeleWave.Application.Library.Collections;
|
||||
using TeleWave.Application.Library.Collections.AddCollectionShow;
|
||||
using TeleWave.Application.Library.Collections.AddShowsToCollection;
|
||||
using TeleWave.Application.Library.Collections.CreateCollection;
|
||||
using TeleWave.Application.Library.Collections.DeleteCollection;
|
||||
using TeleWave.Application.Library.Collections.GetCollection;
|
||||
@@ -9,6 +10,7 @@ using TeleWave.Application.Library.Collections.ListCollections;
|
||||
using TeleWave.Application.Library.Collections.RemoveCollectionShow;
|
||||
using TeleWave.Application.Library.Collections.ReorderCollection;
|
||||
using TeleWave.Application.Library.Collections.SetCollectionPoster;
|
||||
using TeleWave.Application.Library.Collections.Suggest;
|
||||
using TeleWave.Application.Library.Collections.UpdateCollection;
|
||||
using TeleWave.Infrastructure.Identity;
|
||||
|
||||
@@ -36,9 +38,62 @@ public static class CollectionEndpoints
|
||||
admin.MapPut("/{id:guid}/order", Reorder).Produces(StatusCodes.Status204NoContent);
|
||||
admin.MapPut("/{id:guid}/poster-image", SetPoster).Produces(StatusCodes.Status204NoContent);
|
||||
|
||||
// Сборка франшиз: массовое добавление отмеченных шоу и предложения по библиотеке.
|
||||
admin.MapPost("/bulk/shows", AddShows).Produces<AddShowsToCollectionResultDto>();
|
||||
admin
|
||||
.MapGet("/suggestions", Suggestions)
|
||||
.Produces<IReadOnlyList<CollectionSuggestionDto>>();
|
||||
admin
|
||||
.MapPost("/suggestions", CreateFromSuggestion)
|
||||
.Produces<CreatedIdResponse>(StatusCodes.Status201Created);
|
||||
|
||||
return app;
|
||||
}
|
||||
|
||||
private static async Task<IResult> AddShows(
|
||||
AddShowsToCollectionBody body,
|
||||
ISender sender,
|
||||
CancellationToken cancellationToken
|
||||
)
|
||||
{
|
||||
var result = await sender.Send(
|
||||
new AddShowsToCollectionCommand(
|
||||
body.ShowIds,
|
||||
body.CollectionId,
|
||||
body.NewCollectionName
|
||||
),
|
||||
cancellationToken
|
||||
);
|
||||
return result.ToHttpResult();
|
||||
}
|
||||
|
||||
private static async Task<IResult> Suggestions(
|
||||
ISender sender,
|
||||
CancellationToken cancellationToken
|
||||
)
|
||||
{
|
||||
var result = await sender.Send(new SuggestCollectionsQuery(), cancellationToken);
|
||||
return Results.Ok(result);
|
||||
}
|
||||
|
||||
private static async Task<IResult> CreateFromSuggestion(
|
||||
CreateCollectionFromSuggestionBody body,
|
||||
ISender sender,
|
||||
CancellationToken cancellationToken
|
||||
)
|
||||
{
|
||||
var result = await sender.Send(
|
||||
new CreateCollectionFromSuggestionCommand(body.Key),
|
||||
cancellationToken
|
||||
);
|
||||
return result.IsSuccess
|
||||
? Results.Created(
|
||||
$"/api/admin/collections/{result.Value}",
|
||||
new CreatedIdResponse(result.Value)
|
||||
)
|
||||
: result.ToHttpResult();
|
||||
}
|
||||
|
||||
private static async Task<IResult> ListCollections(
|
||||
ISender sender,
|
||||
CancellationToken cancellationToken
|
||||
@@ -161,3 +216,12 @@ public sealed record CollectionShowBody(Guid ShowId);
|
||||
public sealed record ReorderCollectionBody(IReadOnlyList<Guid> ShowIdsInOrder);
|
||||
|
||||
public sealed record CollectionPosterBody(Guid? ImageId);
|
||||
|
||||
/// <summary>Куда складывать: существующая коллекция либо новая по имени.</summary>
|
||||
public sealed record AddShowsToCollectionBody(
|
||||
IReadOnlyList<Guid> ShowIds,
|
||||
Guid? CollectionId = null,
|
||||
string? NewCollectionName = null
|
||||
);
|
||||
|
||||
public sealed record CreateCollectionFromSuggestionBody(string Key);
|
||||
|
||||
Reference in New Issue
Block a user