Implement bulk tagging and enriching of shows with new API endpoints and frontend integration
Added new API endpoints for bulk tagging and enriching shows, allowing for mass updates of genres and audience ratings. Implemented backend logic to handle bulk operations and updated the Dependency Injection configuration to include necessary services. Enhanced the frontend with new components for selecting shows and applying bulk actions, improving the user experience for managing multiple shows simultaneously. 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;
|
||||
using TeleWave.Application.Library.AddEpisode;
|
||||
using TeleWave.Application.Library.BulkTagShows;
|
||||
using TeleWave.Application.Library.CreateShow;
|
||||
using TeleWave.Application.Library.DeleteShow;
|
||||
using TeleWave.Application.Library.GetShow;
|
||||
@@ -11,6 +12,7 @@ using TeleWave.Application.Library.RenameShow;
|
||||
using TeleWave.Application.Library.SetShowAudience;
|
||||
using TeleWave.Application.Library.SetShowGenres;
|
||||
using TeleWave.Application.Library.SetShowOriginalName;
|
||||
using TeleWave.Application.Metadata.EnrichShows;
|
||||
using TeleWave.Domain.Library;
|
||||
using TeleWave.Infrastructure.Identity;
|
||||
|
||||
@@ -34,6 +36,10 @@ public static class ShowEndpoints
|
||||
admin.MapPut("/{id:guid}/audience", SetAudience).Produces(StatusCodes.Status204NoContent);
|
||||
admin.MapPut("/{id:guid}/genres", SetGenres).Produces(StatusCodes.Status204NoContent);
|
||||
admin.MapDelete("/{id:guid}", DeleteShow).Produces(StatusCodes.Status204NoContent);
|
||||
|
||||
// Массовые операции над отмеченными шоу: разметка руками и обогащение из источника.
|
||||
admin.MapPost("/bulk/tag", BulkTag).Produces<BulkTaggedResponse>();
|
||||
admin.MapPost("/bulk/enrich", BulkEnrich).Produces<EnrichShowsResultDto>();
|
||||
admin
|
||||
.MapPost("/{id:guid}/episodes", AddEpisode)
|
||||
.Produces<CreatedIdResponse>(StatusCodes.Status201Created);
|
||||
@@ -172,10 +178,58 @@ public static class ShowEndpoints
|
||||
var result = await sender.Send(new RemoveEpisodeCommand(id, episodeId), cancellationToken);
|
||||
return result.ToHttpResult();
|
||||
}
|
||||
|
||||
private static async Task<IResult> BulkTag(
|
||||
BulkTagShowsBody body,
|
||||
ISender sender,
|
||||
CancellationToken cancellationToken
|
||||
)
|
||||
{
|
||||
var result = await sender.Send(
|
||||
new BulkTagShowsCommand(
|
||||
body.ShowIds,
|
||||
body.GenreIds,
|
||||
body.ReplaceGenres,
|
||||
body.Audience,
|
||||
body.SetAudience
|
||||
),
|
||||
cancellationToken
|
||||
);
|
||||
return result.IsSuccess
|
||||
? Results.Ok(new BulkTaggedResponse(result.Value))
|
||||
: result.ToHttpResult();
|
||||
}
|
||||
|
||||
private static async Task<IResult> BulkEnrich(
|
||||
BulkEnrichBody body,
|
||||
ISender sender,
|
||||
CancellationToken cancellationToken
|
||||
)
|
||||
{
|
||||
var result = await sender.Send(
|
||||
new EnrichShowsMetadataCommand(body.ShowIds, body.Provider),
|
||||
cancellationToken
|
||||
);
|
||||
return result.ToHttpResult();
|
||||
}
|
||||
}
|
||||
|
||||
public sealed record AddEpisodeBody(Guid MediaAssetId);
|
||||
|
||||
/// <summary>Массовая разметка: жанры и рейтинг применяются независимо друг от друга.</summary>
|
||||
public sealed record BulkTagShowsBody(
|
||||
IReadOnlyList<Guid> ShowIds,
|
||||
IReadOnlyList<Guid>? GenreIds = null,
|
||||
bool ReplaceGenres = false,
|
||||
ShowAudience? Audience = null,
|
||||
bool SetAudience = false
|
||||
);
|
||||
|
||||
public sealed record BulkEnrichBody(IReadOnlyList<Guid> ShowIds, string Provider);
|
||||
|
||||
/// <summary>Скольких шоу коснулась массовая правка.</summary>
|
||||
public sealed record BulkTaggedResponse(int Updated);
|
||||
|
||||
public sealed record RenameShowBody(string Name);
|
||||
|
||||
public sealed record SetShowOriginalNameBody(string? OriginalName);
|
||||
|
||||
Reference in New Issue
Block a user