Refactor code formatting and improve readability: standardize line breaks and indentation across various endpoint files, enhancing code clarity and maintainability. Update package version formatting in Directory.Packages.props for consistency.

This commit is contained in:
Leonid Pershin
2026-07-25 19:55:01 +03:00
parent 1f6fa6f1ae
commit f57b7503ed
122 changed files with 1856 additions and 892 deletions
@@ -24,12 +24,8 @@ public static class AdminUserEndpoints
admin.MapGet("", ListUsers).Produces<PagedList<UserSummaryDto>>();
admin.MapPost("", CreateUser).Produces<CreatedIdResponse>(StatusCodes.Status201Created);
admin.MapGet("/{id:guid}", GetUser).Produces<UserSummaryDto>();
admin
.MapPost("/{id:guid}/block", BlockUser)
.Produces(StatusCodes.Status204NoContent);
admin
.MapPost("/{id:guid}/unblock", UnblockUser)
.Produces(StatusCodes.Status204NoContent);
admin.MapPost("/{id:guid}/block", BlockUser).Produces(StatusCodes.Status204NoContent);
admin.MapPost("/{id:guid}/unblock", UnblockUser).Produces(StatusCodes.Status204NoContent);
admin
.MapPost("/{id:guid}/password", ResetPassword)
.Produces(StatusCodes.Status204NoContent);
@@ -49,7 +45,13 @@ public static class AdminUserEndpoints
)
{
var result = await sender.Send(
new ListUsersQuery(page <= 0 ? 1 : page, pageSize <= 0 ? 20 : pageSize, search, roleId, isBlocked),
new ListUsersQuery(
page <= 0 ? 1 : page,
pageSize <= 0 ? 20 : pageSize,
search,
roleId,
isBlocked
),
cancellationToken
);
return Results.Ok(result);
@@ -66,7 +68,10 @@ public static class AdminUserEndpoints
cancellationToken
);
return result.IsSuccess
? Results.Created($"/api/admin/users/{result.Value}", new CreatedIdResponse(result.Value))
? Results.Created(
$"/api/admin/users/{result.Value}",
new CreatedIdResponse(result.Value)
)
: result.ToHttpResult();
}
@@ -40,7 +40,9 @@ public static class ChannelEndpoints
admin.MapPost("", CreateChannel).Produces<CreatedIdResponse>(StatusCodes.Status201Created);
admin.MapGet("", ListChannels).Produces<IReadOnlyList<ChannelSummaryDto>>();
admin.MapGet("/{id:guid}", GetChannel).Produces<ChannelDto>();
admin.MapPut("/{id:guid}/settings", UpdateSettings).Produces(StatusCodes.Status204NoContent);
admin
.MapPut("/{id:guid}/settings", UpdateSettings)
.Produces(StatusCodes.Status204NoContent);
admin
.MapPost("/{id:guid}/shows", AddShow)
@@ -75,10 +77,16 @@ public static class ChannelEndpoints
.MapDelete("/{id:guid}/bumper/templates/{templateId:guid}/audio", ClearTemplateAudio)
.Produces(StatusCodes.Status204NoContent);
admin
.MapPut("/{id:guid}/bumper/templates/{templateId:guid}/background", SetTemplateBackground)
.MapPut(
"/{id:guid}/bumper/templates/{templateId:guid}/background",
SetTemplateBackground
)
.Produces(StatusCodes.Status204NoContent);
admin
.MapDelete("/{id:guid}/bumper/templates/{templateId:guid}/background", ClearTemplateBackground)
.MapDelete(
"/{id:guid}/bumper/templates/{templateId:guid}/background",
ClearTemplateBackground
)
.Produces(StatusCodes.Status204NoContent);
admin
@@ -139,7 +147,10 @@ public static class ChannelEndpoints
: result.ToHttpResult();
}
private static async Task<IResult> ListChannels(ISender sender, CancellationToken cancellationToken)
private static async Task<IResult> ListChannels(
ISender sender,
CancellationToken cancellationToken
)
{
var result = await sender.Send(new ListChannelsQuery(), cancellationToken);
return Results.Ok(result);
@@ -186,7 +197,13 @@ public static class ChannelEndpoints
)
{
var result = await sender.Send(
new AddChannelShowCommand(id, body.ShowId, body.Weight, body.BlockMode, body.BlockValue),
new AddChannelShowCommand(
id,
body.ShowId,
body.Weight,
body.BlockMode,
body.BlockValue
),
cancellationToken
);
return result.IsSuccess
@@ -225,7 +242,10 @@ public static class ChannelEndpoints
CancellationToken cancellationToken
)
{
var result = await sender.Send(new RemoveChannelShowCommand(id, channelShowId), cancellationToken);
var result = await sender.Send(
new RemoveChannelShowCommand(id, channelShowId),
cancellationToken
);
return result.ToHttpResult();
}
@@ -236,7 +256,10 @@ public static class ChannelEndpoints
CancellationToken cancellationToken
)
{
var result = await sender.Send(new AddChannelAdCommand(id, body.MediaAssetId), cancellationToken);
var result = await sender.Send(
new AddChannelAdCommand(id, body.MediaAssetId),
cancellationToken
);
return result.IsSuccess
? Results.Created($"/api/admin/channels/{id}", new CreatedIdResponse(result.Value))
: result.ToHttpResult();
@@ -249,7 +272,10 @@ public static class ChannelEndpoints
CancellationToken cancellationToken
)
{
var result = await sender.Send(new RemoveChannelAdCommand(id, channelAdId), cancellationToken);
var result = await sender.Send(
new RemoveChannelAdCommand(id, channelAdId),
cancellationToken
);
return result.ToHttpResult();
}
@@ -456,7 +482,12 @@ public static class ChannelEndpoints
}
/// <summary>Плейлист превью подблока: переписываем ffmpeg-index.m3u8, направляя сегменты на admin-роут.</summary>
private static IResult PreviewPlaylist(Guid id, Guid templateId, Guid variantId, MediaPathResolver paths)
private static IResult PreviewPlaylist(
Guid id,
Guid templateId,
Guid variantId,
MediaPathResolver paths
)
{
var previewId = BumperPreview.AssetId(variantId);
string indexPath;
@@ -471,7 +502,8 @@ public static class ChannelEndpoints
if (!File.Exists(indexPath))
return Results.NotFound();
var baseUrl = $"/api/admin/channels/{id}/bumper/templates/{templateId}/preview/{variantId}/";
var baseUrl =
$"/api/admin/channels/{id}/bumper/templates/{templateId}/preview/{variantId}/";
var sb = new StringBuilder();
foreach (var line in File.ReadLines(indexPath))
{
@@ -605,7 +637,12 @@ public sealed record UpdateChannelSettingsBody(
Guid? FillerAssetId
);
public sealed record AddChannelShowBody(Guid ShowId, int Weight, BlockMode BlockMode, int BlockValue);
public sealed record AddChannelShowBody(
Guid ShowId,
int Weight,
BlockMode BlockMode,
int BlockValue
);
public sealed record UpdateChannelShowBody(
int Weight,
@@ -86,7 +86,10 @@ public static class ImageEndpoints
throw;
}
return Results.Created($"/api/images/{created.Value}", new CreatedIdResponse(created.Value));
return Results.Created(
$"/api/images/{created.Value}",
new CreatedIdResponse(created.Value)
);
}
private static async Task<IResult> DeleteImage(
@@ -22,13 +22,19 @@ public static class MaintenanceEndpoints
return app;
}
private static async Task<IResult> ClearMedia(ISender sender, CancellationToken cancellationToken)
private static async Task<IResult> ClearMedia(
ISender sender,
CancellationToken cancellationToken
)
{
var result = await sender.Send(new ClearAllMediaCommand(), cancellationToken);
return result.ToHttpResult();
}
private static async Task<IResult> ClearShows(ISender sender, CancellationToken cancellationToken)
private static async Task<IResult> ClearShows(
ISender sender,
CancellationToken cancellationToken
)
{
var result = await sender.Send(new DeleteAllShowsCommand(), cancellationToken);
return result.ToHttpResult();
@@ -9,8 +9,8 @@ using TeleWave.Application.Media.GetMedia;
using TeleWave.Application.Media.ListMedia;
using TeleWave.Application.Media.Register;
using TeleWave.Domain.Media;
using TeleWave.Infrastructure.Media;
using TeleWave.Infrastructure.Identity;
using TeleWave.Infrastructure.Media;
namespace TeleWave.Api.Endpoints;
@@ -89,7 +89,10 @@ public static class MediaEndpoints
}
queue.Enqueue(result.Value);
return Results.Created($"/api/admin/media/{result.Value}", new UploadMediaResponse(result.Value));
return Results.Created(
$"/api/admin/media/{result.Value}",
new UploadMediaResponse(result.Value)
);
}
private static async Task<IResult> List(
@@ -41,7 +41,9 @@ public static class MetadataEndpoints
admin.MapPost("/shows/{showId:guid}/apply", Apply).Produces(StatusCodes.Status204NoContent);
admin.MapPut("/shows/{showId:guid}", Update).Produces(StatusCodes.Status204NoContent);
admin.MapDelete("/shows/{showId:guid}", Clear).Produces(StatusCodes.Status204NoContent);
admin.MapPut("/shows/{showId:guid}/poster", UploadPoster).Produces(StatusCodes.Status204NoContent);
admin
.MapPut("/shows/{showId:guid}/poster", UploadPoster)
.Produces(StatusCodes.Status204NoContent);
admin
.MapPut("/shows/{showId:guid}/poster-image", SetPosterImage)
.Produces(StatusCodes.Status204NoContent);
@@ -51,7 +53,10 @@ public static class MetadataEndpoints
return app;
}
private static async Task<IResult> GetProviders(ISender sender, CancellationToken cancellationToken)
private static async Task<IResult> GetProviders(
ISender sender,
CancellationToken cancellationToken
)
{
var providers = await sender.Send(new GetMetadataProvidersQuery(), cancellationToken);
return Results.Ok(providers);
@@ -64,7 +69,10 @@ public static class MetadataEndpoints
CancellationToken cancellationToken
)
{
var result = await sender.Send(new SearchShowMetadataQuery(provider, query), cancellationToken);
var result = await sender.Send(
new SearchShowMetadataQuery(provider, query),
cancellationToken
);
return result.ToHttpResult();
}
@@ -29,7 +29,10 @@ public static class RoleEndpoints
return app;
}
private static async Task<IResult> ListRoles(ISender sender, CancellationToken cancellationToken)
private static async Task<IResult> ListRoles(
ISender sender,
CancellationToken cancellationToken
)
{
var roles = await sender.Send(new ListRolesQuery(), cancellationToken);
return Results.Ok(roles);
@@ -21,7 +21,10 @@ public static class SettingsEndpoints
return app;
}
private static async Task<IResult> GetSettings(ISender sender, CancellationToken cancellationToken)
private static async Task<IResult> GetSettings(
ISender sender,
CancellationToken cancellationToken
)
{
var settings = await sender.Send(new GetSiteSettingsQuery(), cancellationToken);
return Results.Ok(settings);
@@ -47,11 +47,17 @@ public static class ShowEndpoints
{
var result = await sender.Send(command, cancellationToken);
return result.IsSuccess
? Results.Created($"/api/admin/shows/{result.Value}", new CreatedIdResponse(result.Value))
? Results.Created(
$"/api/admin/shows/{result.Value}",
new CreatedIdResponse(result.Value)
)
: result.ToHttpResult();
}
private static async Task<IResult> ListShows(ISender sender, CancellationToken cancellationToken)
private static async Task<IResult> ListShows(
ISender sender,
CancellationToken cancellationToken
)
{
var result = await sender.Send(new ListShowsQuery(), cancellationToken);
return Results.Ok(result);
@@ -109,7 +115,10 @@ public static class ShowEndpoints
CancellationToken cancellationToken
)
{
var result = await sender.Send(new AddEpisodeCommand(id, body.MediaAssetId), cancellationToken);
var result = await sender.Send(
new AddEpisodeCommand(id, body.MediaAssetId),
cancellationToken
);
return result.IsSuccess
? Results.Created($"/api/admin/shows/{id}", new CreatedIdResponse(result.Value))
: result.ToHttpResult();
@@ -33,7 +33,10 @@ public static class StreamingEndpoints
return app;
}
private static async Task<IResult> ListChannels(ISender sender, CancellationToken cancellationToken)
private static async Task<IResult> ListChannels(
ISender sender,
CancellationToken cancellationToken
)
{
var result = await sender.Send(new ListPublicChannelsQuery(), cancellationToken);
return Results.Ok(result);
@@ -145,8 +148,14 @@ public static class StreamingEndpoints
var sb = new StringBuilder();
sb.Append("#EXTM3U\n");
sb.Append("#EXT-X-VERSION:3\n");
sb.Append(CultureInfo.InvariantCulture, $"#EXT-X-TARGETDURATION:{playlist.TargetDuration}\n");
sb.Append(CultureInfo.InvariantCulture, $"#EXT-X-MEDIA-SEQUENCE:{playlist.MediaSequence}\n");
sb.Append(
CultureInfo.InvariantCulture,
$"#EXT-X-TARGETDURATION:{playlist.TargetDuration}\n"
);
sb.Append(
CultureInfo.InvariantCulture,
$"#EXT-X-MEDIA-SEQUENCE:{playlist.MediaSequence}\n"
);
foreach (var segment in playlist.Segments)
{
+2 -2
View File
@@ -2,14 +2,14 @@ using System.Net;
using System.Text.Json.Serialization;
using Microsoft.AspNetCore.HttpOverrides;
using Microsoft.AspNetCore.RateLimiting;
using Scalar.AspNetCore;
using Serilog;
using TeleWave.Api.Common;
using TeleWave.Api.Endpoints;
using TeleWave.Application;
using TeleWave.Infrastructure;
using TeleWave.Infrastructure.Identity;
using TeleWave.Infrastructure.Persistence;
using Scalar.AspNetCore;
using Serilog;
var builder = WebApplication.CreateBuilder(args);