Enhance code readability and maintainability by refactoring various components. Update formatting commands in CLAUDE.md for csharpier integration. Simplify method signatures in SegmentFiles, UploadLimits, and multiple endpoint classes for improved clarity. Adjust query handlers and command handlers to streamline parameter handling and enhance consistency across the application.
This commit is contained in:
@@ -17,11 +17,7 @@ internal static partial class SegmentFiles
|
||||
public static bool IsSegmentName(string file) => SegmentName().IsMatch(file);
|
||||
|
||||
/// <summary>Путь к существующему файлу нарезки, либо null — если имя опасно или файла нет.</summary>
|
||||
public static string? TryResolveExisting(
|
||||
MediaPathResolver paths,
|
||||
Guid assetId,
|
||||
string fileName
|
||||
)
|
||||
public static string? TryResolveExisting(MediaPathResolver paths, Guid assetId, string fileName)
|
||||
{
|
||||
string path;
|
||||
try
|
||||
|
||||
@@ -8,10 +8,7 @@ namespace TeleWave.Api.Common;
|
||||
/// (<c>Media</c> и <c>Storage</c>), но проверяются всегда вместе и только на входе загрузки —
|
||||
/// хендлеру незачем знать про обе секции и тащить два <see cref="IOptions{T}"/> в сигнатуре.
|
||||
/// </summary>
|
||||
public sealed class UploadLimits(
|
||||
IOptions<MediaOptions> media,
|
||||
IOptions<StorageOptions> storage
|
||||
)
|
||||
public sealed class UploadLimits(IOptions<MediaOptions> media, IOptions<StorageOptions> storage)
|
||||
{
|
||||
/// <summary>Потолок размера загружаемого файла.</summary>
|
||||
public long MaxUploadBytes { get; } = media.Value.MaxUploadBytes;
|
||||
|
||||
@@ -7,10 +7,10 @@ using TeleWave.Application.Broadcast.GetSchedule;
|
||||
using TeleWave.Application.Broadcast.ListChannels;
|
||||
using TeleWave.Application.Broadcast.UpdateChannelSettings;
|
||||
using TeleWave.Application.Broadcast.UpdateChannelTime;
|
||||
using TeleWave.Domain.Broadcast;
|
||||
using TeleWave.Infrastructure.Identity;
|
||||
using TeleWave.Application.Broadcast.UpdateViewerSettings;
|
||||
using TeleWave.Application.Programming.Planning.Trace;
|
||||
using TeleWave.Domain.Broadcast;
|
||||
using TeleWave.Infrastructure.Identity;
|
||||
|
||||
namespace TeleWave.Api.Endpoints;
|
||||
|
||||
@@ -177,12 +177,7 @@ public static partial class ChannelEndpoints
|
||||
)
|
||||
{
|
||||
var result = await sender.Send(
|
||||
new UpdateChannelTimeCommand(
|
||||
id,
|
||||
body.Number,
|
||||
body.UtcOffsetMinutes,
|
||||
body.DayStartTime
|
||||
),
|
||||
new UpdateChannelTimeCommand(id, body.Number, body.UtcOffsetMinutes, body.DayStartTime),
|
||||
cancellationToken
|
||||
);
|
||||
return result.ToHttpResult();
|
||||
@@ -209,7 +204,6 @@ public static partial class ChannelEndpoints
|
||||
return result.ToHttpResult();
|
||||
}
|
||||
|
||||
|
||||
private static async Task<IResult> GetSchedule(
|
||||
Guid id,
|
||||
DateTimeOffset? from,
|
||||
|
||||
@@ -30,7 +30,8 @@ public static class GroupEndpoints
|
||||
admin.MapDelete("/{id:guid}", DeleteGroup).Produces(StatusCodes.Status204NoContent);
|
||||
|
||||
// Подбор по правилу набора: правило можно передать в теле, чтобы крутить его до сохранения.
|
||||
admin.MapPost("/{id:guid}/candidates", FindCandidates)
|
||||
admin
|
||||
.MapPost("/{id:guid}/candidates", FindCandidates)
|
||||
.Produces<IReadOnlyList<GroupCandidateDto>>();
|
||||
|
||||
admin.MapPost("/{id:guid}/items", AddElements).Produces<AddedCountResponse>();
|
||||
@@ -45,7 +46,10 @@ public static class GroupEndpoints
|
||||
return app;
|
||||
}
|
||||
|
||||
private static async Task<IResult> ListGroups(ISender sender, CancellationToken cancellationToken)
|
||||
private static async Task<IResult> ListGroups(
|
||||
ISender sender,
|
||||
CancellationToken cancellationToken
|
||||
)
|
||||
{
|
||||
var result = await sender.Send(new ListGroupsQuery(), cancellationToken);
|
||||
return Results.Ok(result);
|
||||
|
||||
@@ -24,7 +24,9 @@ public static class JunctionEndpoints
|
||||
admin
|
||||
.MapPost("/channels/{channelId:guid}/junctions", Create)
|
||||
.Produces<CreatedIdResponse>(StatusCodes.Status201Created);
|
||||
admin.MapPut("/junctions/{junctionId:guid}", Rename).Produces(StatusCodes.Status204NoContent);
|
||||
admin
|
||||
.MapPut("/junctions/{junctionId:guid}", Rename)
|
||||
.Produces(StatusCodes.Status204NoContent);
|
||||
admin
|
||||
.MapDelete("/junctions/{junctionId:guid}", Delete)
|
||||
.Produces(StatusCodes.Status204NoContent);
|
||||
|
||||
@@ -141,7 +141,10 @@ public static class MediaEndpoints
|
||||
return result.ToHttpResult();
|
||||
}
|
||||
|
||||
private static async Task<IResult> ListManual(ISender sender, CancellationToken cancellationToken)
|
||||
private static async Task<IResult> ListManual(
|
||||
ISender sender,
|
||||
CancellationToken cancellationToken
|
||||
)
|
||||
{
|
||||
var result = await sender.Send(new ListManualInboxQuery(), cancellationToken);
|
||||
return Results.Ok(result);
|
||||
|
||||
@@ -66,7 +66,10 @@ public static class ShowEndpoints
|
||||
bool interstitials = false
|
||||
)
|
||||
{
|
||||
var result = await sender.Send(new ListShowsQuery(genreId, interstitials), cancellationToken);
|
||||
var result = await sender.Send(
|
||||
new ListShowsQuery(genreId, interstitials),
|
||||
cancellationToken
|
||||
);
|
||||
return Results.Ok(result);
|
||||
}
|
||||
|
||||
|
||||
@@ -48,7 +48,9 @@ public static class StreamingEndpoints
|
||||
CancellationToken cancellationToken
|
||||
) =>
|
||||
Results.Ok(
|
||||
new ViewerFeaturesDto(await siteSettings.AreChannelNumbersEnabledAsync(cancellationToken))
|
||||
new ViewerFeaturesDto(
|
||||
await siteSettings.AreChannelNumbersEnabledAsync(cancellationToken)
|
||||
)
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -56,13 +56,18 @@ public static class TemplateEndpoints
|
||||
.MapGet("/channels/{channelId:guid}/template/diff", DiffTemplate)
|
||||
.Produces<ScheduleDiffDto>();
|
||||
admin
|
||||
.MapPost("/channels/{channelId:guid}/template/copy-to/{targetChannelId:guid}", CopyTemplate)
|
||||
.MapPost(
|
||||
"/channels/{channelId:guid}/template/copy-to/{targetChannelId:guid}",
|
||||
CopyTemplate
|
||||
)
|
||||
.Produces<CopyTemplateResultDto>();
|
||||
|
||||
admin
|
||||
.MapPost("/templates/{templateId:guid}/layers", CreateLayer)
|
||||
.Produces<CreatedIdResponse>(StatusCodes.Status201Created);
|
||||
admin.MapPut("/layers/{layerId:guid}", UpdateLayer).Produces(StatusCodes.Status204NoContent);
|
||||
admin
|
||||
.MapPut("/layers/{layerId:guid}", UpdateLayer)
|
||||
.Produces(StatusCodes.Status204NoContent);
|
||||
admin
|
||||
.MapDelete("/layers/{layerId:guid}", DeleteLayer)
|
||||
.Produces(StatusCodes.Status204NoContent);
|
||||
@@ -71,7 +76,9 @@ public static class TemplateEndpoints
|
||||
.MapPost("/layers/{layerId:guid}/slots", CreateSlot)
|
||||
.Produces<CreatedIdResponse>(StatusCodes.Status201Created);
|
||||
admin.MapPut("/slots/{slotId:guid}", UpdateSlot).Produces(StatusCodes.Status204NoContent);
|
||||
admin.MapDelete("/slots/{slotId:guid}", DeleteSlot).Produces(StatusCodes.Status204NoContent);
|
||||
admin
|
||||
.MapDelete("/slots/{slotId:guid}", DeleteSlot)
|
||||
.Produces(StatusCodes.Status204NoContent);
|
||||
|
||||
return app;
|
||||
}
|
||||
@@ -197,7 +204,10 @@ public static class TemplateEndpoints
|
||||
cancellationToken
|
||||
);
|
||||
return result.IsSuccess
|
||||
? Results.Created($"/api/admin/layers/{result.Value}", new CreatedIdResponse(result.Value))
|
||||
? Results.Created(
|
||||
$"/api/admin/layers/{result.Value}",
|
||||
new CreatedIdResponse(result.Value)
|
||||
)
|
||||
: result.ToHttpResult();
|
||||
}
|
||||
|
||||
@@ -240,7 +250,10 @@ public static class TemplateEndpoints
|
||||
{
|
||||
var result = await sender.Send(new CreateSlotCommand(layerId, input), cancellationToken);
|
||||
return result.IsSuccess
|
||||
? Results.Created($"/api/admin/slots/{result.Value}", new CreatedIdResponse(result.Value))
|
||||
? Results.Created(
|
||||
$"/api/admin/slots/{result.Value}",
|
||||
new CreatedIdResponse(result.Value)
|
||||
)
|
||||
: result.ToHttpResult();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user