Remove downloads management features: delete DownloadsEndpoints and related API logic, remove associated frontend components and routes, and update documentation to reflect the removal of the downloads directory from the application structure.
This commit is contained in:
@@ -1,52 +0,0 @@
|
||||
using LiteCqrs;
|
||||
using TeleWave.Api.Common;
|
||||
using TeleWave.Application.Common.Interfaces;
|
||||
using TeleWave.Application.Media.Downloads;
|
||||
using TeleWave.Application.Media.Register;
|
||||
using TeleWave.Domain.Media;
|
||||
using TeleWave.Infrastructure.Identity;
|
||||
|
||||
namespace TeleWave.Api.Endpoints;
|
||||
|
||||
public static class DownloadsEndpoints
|
||||
{
|
||||
public static IEndpointRouteBuilder MapDownloadsEndpoints(this IEndpointRouteBuilder app)
|
||||
{
|
||||
var admin = app.MapGroup("/api/admin/downloads")
|
||||
.WithTags("Admin.Downloads")
|
||||
.RequireAuthorization(policy => policy.RequireRole(RoleNames.Admin));
|
||||
|
||||
admin.MapGet("", List).Produces<IReadOnlyList<DownloadFileDto>>();
|
||||
admin.MapPost("/import", Import).Produces<CreatedIdResponse>(StatusCodes.Status201Created);
|
||||
|
||||
return app;
|
||||
}
|
||||
|
||||
private static async Task<IResult> List(ISender sender, CancellationToken cancellationToken)
|
||||
{
|
||||
var result = await sender.Send(new ListDownloadsQuery(), cancellationToken);
|
||||
return Results.Ok(result);
|
||||
}
|
||||
|
||||
/// <summary>Импорт выбранного файла из downloads/: регистрирует ассет (копией) и ставит в обработку.</summary>
|
||||
private static async Task<IResult> Import(
|
||||
ImportDownloadBody body,
|
||||
ISender sender,
|
||||
IMediaProcessingQueue queue,
|
||||
CancellationToken cancellationToken
|
||||
)
|
||||
{
|
||||
var fileName = Path.GetFileName(body.RelativePath);
|
||||
var result = await sender.Send(
|
||||
new RegisterMediaAssetCommand(body.RelativePath, MediaSource.Download, fileName),
|
||||
cancellationToken
|
||||
);
|
||||
if (!result.IsSuccess)
|
||||
return result.ToHttpResult();
|
||||
|
||||
queue.Enqueue(result.Value);
|
||||
return Results.Created($"/api/admin/media/{result.Value}", new CreatedIdResponse(result.Value));
|
||||
}
|
||||
}
|
||||
|
||||
public sealed record ImportDownloadBody(string RelativePath);
|
||||
Reference in New Issue
Block a user