Add admin maintenance endpoints and file deletion functionality
- Introduced a new `/api/admin/maintenance` route for administrative maintenance tasks, requiring admin authorization. - Implemented the `DeleteAsync` method in `IFileStorage` to allow for the deletion of files associated with closed support tickets. - Updated API documentation to include details about the new maintenance operations and their effects on closed tickets. - Enhanced frontend routing to include the new maintenance section in the admin panel, improving navigation for administrators. - Added localization support for maintenance-related actions in both Russian and English.
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
using PnvPanel.Api.Common;
|
||||
using PnvPanel.Application.Admin.Maintenance;
|
||||
using PnvPanel.Application.Common.Messaging;
|
||||
using PnvPanel.Infrastructure.Identity;
|
||||
|
||||
namespace PnvPanel.Api.Endpoints;
|
||||
|
||||
public static class AdminMaintenanceEndpoints
|
||||
{
|
||||
public static IEndpointRouteBuilder MapAdminMaintenanceEndpoints(this IEndpointRouteBuilder app)
|
||||
{
|
||||
var admin = app.MapGroup("/api/admin/maintenance")
|
||||
.WithTags("Admin.Maintenance")
|
||||
.RequireAuthorization(policy => policy.RequireRole(RoleNames.Admin));
|
||||
|
||||
admin
|
||||
.MapDelete("/tickets/closed", DeleteClosedTickets)
|
||||
.Produces<DeleteClosedTicketsResponseDto>();
|
||||
|
||||
return app;
|
||||
}
|
||||
|
||||
private static async Task<IResult> DeleteClosedTickets(
|
||||
ISender sender,
|
||||
CancellationToken cancellationToken
|
||||
)
|
||||
{
|
||||
var result = await sender.Send(new DeleteClosedTicketsCommand(), cancellationToken);
|
||||
if (!result.IsSuccess)
|
||||
return result.ToHttpResult();
|
||||
|
||||
return Results.Ok(new DeleteClosedTicketsResponseDto(result.Value));
|
||||
}
|
||||
}
|
||||
|
||||
public sealed record DeleteClosedTicketsResponseDto(int DeletedCount);
|
||||
@@ -191,6 +191,7 @@ app.MapAdminAppEndpoints();
|
||||
app.MapAdminNewsEndpoints();
|
||||
app.MapSupportEndpoints();
|
||||
app.MapAdminSupportEndpoints();
|
||||
app.MapAdminMaintenanceEndpoints();
|
||||
app.MapTelegramEndpoints();
|
||||
|
||||
app.MapHub<PanelHub>("/hubs/panel");
|
||||
|
||||
Reference in New Issue
Block a user