Added new BumperEndpoints to the API for managing bumper templates and variants, enhancing the channel management capabilities. Removed outdated bumper-related commands and handlers from the application, streamlining the codebase and improving maintainability. Updated ChannelEndpoints to reflect these changes and ensure proper routing for the new endpoints.
81 lines
3.2 KiB
C#
81 lines
3.2 KiB
C#
namespace TeleWave.Domain.Broadcast;
|
|
|
|
/// <summary>
|
|
/// Подблок заставки (текст-вариант) внутри <see cref="BumperTemplate"/>. Наследует от блока звук,
|
|
/// стиль и шрифт, но задаёт собственный набор строк, фон и правило показа (<see cref="Trigger"/>).
|
|
/// Позволяет иметь несколько текстов на одной музыке/оформлении, не дублируя блок.
|
|
/// </summary>
|
|
public class BumperTextVariant
|
|
{
|
|
private readonly List<BumperLine> _lines = [];
|
|
|
|
public Guid Id { get; private set; }
|
|
public Guid BumperTemplateId { get; private set; }
|
|
public int Position { get; private set; }
|
|
public string Name { get; private set; } = string.Empty;
|
|
|
|
public BumperTrigger Trigger { get; private set; }
|
|
|
|
/// <summary>Источник картинки под текстом.</summary>
|
|
public BumperBackground Background { get; private set; }
|
|
|
|
/// <summary>Вес при выборе подблока на переходе (0 — не выбирается никогда).</summary>
|
|
public int Weight { get; private set; } = DefaultWeight;
|
|
|
|
public DateTimeOffset CreatedAt { get; private set; }
|
|
|
|
public const int DefaultWeight = 1;
|
|
|
|
/// <summary>Строки в порядке показа сверху вниз.</summary>
|
|
public IReadOnlyList<BumperLine> Lines => _lines;
|
|
|
|
private BumperTextVariant() { }
|
|
|
|
internal static BumperTextVariant Create(
|
|
Guid bumperTemplateId,
|
|
int position,
|
|
string name,
|
|
BumperTrigger trigger
|
|
) =>
|
|
new()
|
|
{
|
|
Id = Guid.NewGuid(),
|
|
BumperTemplateId = bumperTemplateId,
|
|
Position = position,
|
|
Name = name,
|
|
Trigger = trigger,
|
|
Background = BumperBackground.NextPoster,
|
|
Weight = DefaultWeight,
|
|
CreatedAt = DateTimeOffset.UtcNow,
|
|
};
|
|
|
|
public void Update(string name, BumperTrigger trigger, BumperBackground background, int weight)
|
|
{
|
|
Name = name;
|
|
Trigger = trigger;
|
|
Background = background;
|
|
Weight = Math.Max(0, weight);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Заменяет набор строк целиком. Построчных команд намеренно нет: редактор всегда знает весь
|
|
/// список, а порядок задаётся перетаскиванием — три команды вместо одной ничего бы не дали.
|
|
/// </summary>
|
|
public void SetLines(IEnumerable<BumperLine> lines)
|
|
{
|
|
_lines.Clear();
|
|
var position = 0;
|
|
foreach (var line in lines)
|
|
_lines.Add(BumperLine.Create(position++, line.Style, line.Color, line.Text));
|
|
}
|
|
|
|
/// <summary>Подходит ли подблок для перехода: <paramref name="isShowChange"/> — сменилось ли шоу.</summary>
|
|
public bool Matches(bool isShowChange) =>
|
|
Trigger switch
|
|
{
|
|
BumperTrigger.OnShowChange => isShowChange,
|
|
BumperTrigger.BetweenEpisodes => !isShowChange,
|
|
_ => true,
|
|
};
|
|
}
|