Refactor various components to improve code clarity and maintainability. Update ListUsersQueryHandler to utilize UserListFilter for parameter handling. Refactor BumperSpecFactory and related classes to encapsulate input parameters into dedicated records, enhancing readability. Adjust MediaAsset and Slot classes to streamline content updates with new content models. Improve BumperRenderBackgroundService and MediaProcessingBackgroundService to use MediaReadyInfo for asset readiness, ensuring consistent parameter management across the application.
This commit is contained in:
@@ -15,11 +15,7 @@ public static class BumperSpecFactory
|
||||
BumperTemplate template,
|
||||
BumperTextVariant variant,
|
||||
int alignedDurationSeconds,
|
||||
string fromName,
|
||||
string toName,
|
||||
string? audioPath,
|
||||
string? posterAbsolutePath,
|
||||
string? backgroundAbsolutePath
|
||||
BumperSpecInputs inputs
|
||||
)
|
||||
{
|
||||
var free = variant.Kind == BumperTextKind.Free;
|
||||
@@ -33,12 +29,12 @@ public static class BumperSpecFactory
|
||||
template.TextColor,
|
||||
font == BumperFont.Serif ? bumper.FontFileSerif : bumper.FontFileSans,
|
||||
free ? "" : variant.NowLabel,
|
||||
free ? "" : fromName,
|
||||
free ? "" : inputs.FromName,
|
||||
free ? "" : variant.NextLabel,
|
||||
free ? "" : toName,
|
||||
backgroundAbsolutePath,
|
||||
audioPath,
|
||||
posterAbsolutePath,
|
||||
free ? "" : inputs.ToName,
|
||||
inputs.BackgroundAbsolutePath,
|
||||
inputs.AudioPath,
|
||||
inputs.PosterAbsolutePath,
|
||||
free,
|
||||
variant.Line1,
|
||||
variant.Line2
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
namespace TeleWave.Application.Broadcast.Bumpers;
|
||||
|
||||
/// <summary>
|
||||
/// Уже разрешённые входы рендера заставки: названия шоу «из/в» и пути к файлам. Разрешает их
|
||||
/// вызывающий (генератор эфира — по реальной паре соседей, превью — по образцам канала), а
|
||||
/// <see cref="BumperSpecFactory"/> только раскладывает их по спецификации.
|
||||
/// </summary>
|
||||
public sealed record BumperSpecInputs(
|
||||
string FromName,
|
||||
string ToName,
|
||||
string? AudioPath = null,
|
||||
/// <summary>Постер «следующего» шоу как фон; в превью не подставляется — шоу ещё неизвестно.</summary>
|
||||
string? PosterAbsolutePath = null,
|
||||
string? BackgroundAbsolutePath = null
|
||||
);
|
||||
@@ -72,11 +72,13 @@ public sealed class BumperSpecLoader(
|
||||
template,
|
||||
variant,
|
||||
aligned,
|
||||
names.GetValueOrDefault(cache.FromShowId, "…"),
|
||||
names.GetValueOrDefault(cache.ToShowId, "…"),
|
||||
bumperStorage.AudioPath(template.Id, template.AudioExtension),
|
||||
posterPath,
|
||||
bgPath
|
||||
new BumperSpecInputs(
|
||||
names.GetValueOrDefault(cache.FromShowId, "…"),
|
||||
names.GetValueOrDefault(cache.ToShowId, "…"),
|
||||
bumperStorage.AudioPath(template.Id, template.AudioExtension),
|
||||
posterPath,
|
||||
bgPath
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
+14
-49
@@ -43,9 +43,6 @@ public sealed class RenderBumperPreviewCommandHandler(
|
||||
return Result.Failure(ChannelErrors.BumperTemplateNotFound);
|
||||
|
||||
var (fromName, toName) = await SampleNamesAsync(channel, cancellationToken);
|
||||
var fontFile =
|
||||
channel.BumperFont == BumperFont.Serif ? _bumper.FontFileSerif : _bumper.FontFileSans;
|
||||
|
||||
var backgroundPath = await ResolveBackgroundPathAsync(template, cancellationToken);
|
||||
var seconds = template.AudioDurationSeconds is { } d and > 0
|
||||
? d
|
||||
@@ -55,18 +52,25 @@ public sealed class RenderBumperPreviewCommandHandler(
|
||||
);
|
||||
var audioPath = storage.AudioPath(template.Id, template.AudioExtension);
|
||||
|
||||
// Постер зависит от конкретного «следующего» шоу — в превью его не подставляем.
|
||||
var inputs = new BumperSpecInputs(
|
||||
fromName,
|
||||
toName,
|
||||
audioPath,
|
||||
PosterAbsolutePath: null,
|
||||
backgroundPath
|
||||
);
|
||||
|
||||
// Рендерим каждый подблок в свой ассет-превью (id по подблоку).
|
||||
foreach (var variant in template.Variants.OrderBy(v => v.Position))
|
||||
{
|
||||
var spec = BuildSpec(
|
||||
variant,
|
||||
var spec = BumperSpecFactory.Build(
|
||||
_bumper,
|
||||
channel.BumperFont,
|
||||
template,
|
||||
variant,
|
||||
aligned,
|
||||
fontFile,
|
||||
backgroundPath,
|
||||
audioPath,
|
||||
fromName,
|
||||
toName
|
||||
inputs
|
||||
);
|
||||
await renderer.RenderAsync(BumperPreview.AssetId(variant.Id), spec, cancellationToken);
|
||||
}
|
||||
@@ -92,45 +96,6 @@ public sealed class RenderBumperPreviewCommandHandler(
|
||||
return extension is null ? null : imageStore.ResolvePath(imageId, extension);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Спецификация рендера одного подблока. В режиме <see cref="BumperTextKind.Free"/> подписи и
|
||||
/// названия шоу гасятся: там на экране произвольные строки, а не «Сейчас/Далее».
|
||||
/// </summary>
|
||||
private BumperRenderSpec BuildSpec(
|
||||
BumperTextVariant variant,
|
||||
BumperTemplate template,
|
||||
int alignedSeconds,
|
||||
string fontFile,
|
||||
string? backgroundPath,
|
||||
string? audioPath,
|
||||
string fromName,
|
||||
string toName
|
||||
)
|
||||
{
|
||||
var free = variant.Kind == BumperTextKind.Free;
|
||||
return new BumperRenderSpec(
|
||||
alignedSeconds,
|
||||
_bumper.Width,
|
||||
_bumper.Height,
|
||||
template.BackgroundColor,
|
||||
template.BackgroundColor2,
|
||||
template.AccentColor,
|
||||
template.TextColor,
|
||||
fontFile,
|
||||
free ? "" : variant.NowLabel,
|
||||
free ? "" : fromName,
|
||||
free ? "" : variant.NextLabel,
|
||||
free ? "" : toName,
|
||||
backgroundPath,
|
||||
audioPath,
|
||||
// Постер зависит от конкретного «следующего» шоу — в превью не подставляем.
|
||||
null,
|
||||
free,
|
||||
variant.Line1,
|
||||
variant.Line2
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Примерные названия «из/в» для превью. Берём шоу из групп, на которые ссылаются слоты канала:
|
||||
/// так превью показывает реальные названия этого канала, а не случайные из библиотеки.
|
||||
|
||||
+8
-5
@@ -2,6 +2,7 @@ using LiteCqrs;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using TeleWave.Application.Common.Interfaces;
|
||||
using TeleWave.Application.Common.Models;
|
||||
using TeleWave.Domain.Broadcast;
|
||||
|
||||
namespace TeleWave.Application.Broadcast.Bumpers;
|
||||
|
||||
@@ -31,11 +32,13 @@ public sealed class UpdateBumperTextVariantCommandHandler(IAppDbContext dbContex
|
||||
|
||||
variant.Update(
|
||||
command.Name.Trim(),
|
||||
command.Kind,
|
||||
command.NowLabel,
|
||||
command.NextLabel,
|
||||
command.Line1,
|
||||
command.Line2,
|
||||
new BumperTextContent(
|
||||
command.Kind,
|
||||
command.NowLabel,
|
||||
command.NextLabel,
|
||||
command.Line1,
|
||||
command.Line2
|
||||
),
|
||||
command.Trigger,
|
||||
command.Weight
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user