Enhance channel and settings functionalities: introduce viewer settings in ChannelEndpoints, update SiteSettings to include channel number toggling, and refactor related data structures. Implement new endpoints for validating templates and diffing scheduling changes, improving overall user experience and configuration management.
This commit is contained in:
@@ -49,5 +49,16 @@ public sealed record ChannelDto(
|
||||
bool BumpersEnabled,
|
||||
BumperSettingsDto Bumper,
|
||||
IReadOnlyList<BumperTemplateDto> BumperTemplates,
|
||||
Guid? FillerAssetId
|
||||
Guid? FillerAssetId,
|
||||
/// <summary>Оверлеи и фильтр зрительской части — всё опционально (см. 6.8).</summary>
|
||||
ViewerSettingsDto Viewer
|
||||
);
|
||||
|
||||
/// <summary>Как канал выглядит у зрителя: логотип-оверлей, часы, аналоговый фильтр.</summary>
|
||||
public sealed record ViewerSettingsDto(
|
||||
Guid? LogoImageId,
|
||||
LogoCorner LogoCorner,
|
||||
double LogoOpacity,
|
||||
bool ShowClock,
|
||||
double AnalogFilterStrength
|
||||
);
|
||||
|
||||
@@ -67,7 +67,14 @@ public sealed class GetChannelQueryHandler(IAppDbContext dbContext)
|
||||
channel.BumpersEnabled,
|
||||
new BumperSettingsDto(channel.BumperFont, channel.BumperSelection),
|
||||
bumperTemplates,
|
||||
channel.FillerAssetId
|
||||
channel.FillerAssetId,
|
||||
new ViewerSettingsDto(
|
||||
channel.LogoImageId,
|
||||
channel.LogoCorner,
|
||||
channel.LogoOpacity,
|
||||
channel.ShowClock,
|
||||
channel.AnalogFilterStrength
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
using FluentValidation;
|
||||
using LiteCqrs;
|
||||
using TeleWave.Application.Common.Models;
|
||||
using TeleWave.Domain.Broadcast;
|
||||
|
||||
namespace TeleWave.Application.Broadcast.UpdateViewerSettings;
|
||||
|
||||
/// <summary>
|
||||
/// Оверлеи и аналоговый фильтр канала (см. 6.8). Отдельной командой, а не в общих настройках:
|
||||
/// это про то, как канал выглядит у зрителя, и правится другими руками и в другой момент.
|
||||
/// </summary>
|
||||
public sealed record UpdateViewerSettingsCommand(
|
||||
Guid ChannelId,
|
||||
Guid? LogoImageId,
|
||||
LogoCorner LogoCorner,
|
||||
double LogoOpacity,
|
||||
bool ShowClock,
|
||||
double AnalogFilterStrength
|
||||
) : ICommand<Result>;
|
||||
|
||||
public sealed class UpdateViewerSettingsCommandValidator
|
||||
: AbstractValidator<UpdateViewerSettingsCommand>
|
||||
{
|
||||
public UpdateViewerSettingsCommandValidator()
|
||||
{
|
||||
RuleFor(x => x.LogoOpacity).InclusiveBetween(0.0, 1.0);
|
||||
RuleFor(x => x.AnalogFilterStrength).InclusiveBetween(0.0, 1.0);
|
||||
}
|
||||
}
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
using LiteCqrs;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using TeleWave.Application.Common.Interfaces;
|
||||
using TeleWave.Application.Common.Models;
|
||||
|
||||
namespace TeleWave.Application.Broadcast.UpdateViewerSettings;
|
||||
|
||||
public sealed class UpdateViewerSettingsCommandHandler(IAppDbContext dbContext)
|
||||
: ICommandHandler<UpdateViewerSettingsCommand, Result>
|
||||
{
|
||||
public async Task<Result> Handle(
|
||||
UpdateViewerSettingsCommand command,
|
||||
CancellationToken cancellationToken
|
||||
)
|
||||
{
|
||||
var channel = await dbContext.Channels.FirstOrDefaultAsync(
|
||||
c => c.Id == command.ChannelId,
|
||||
cancellationToken
|
||||
);
|
||||
if (channel is null)
|
||||
return Result.Failure(ChannelErrors.NotFound);
|
||||
|
||||
if (
|
||||
command.LogoImageId is { } imageId
|
||||
&& !await dbContext.Images.AnyAsync(i => i.Id == imageId, cancellationToken)
|
||||
)
|
||||
return Result.Failure(ChannelErrors.AssetNotFound);
|
||||
|
||||
channel.UpdateViewerSettings(
|
||||
command.LogoImageId,
|
||||
command.LogoCorner,
|
||||
command.LogoOpacity,
|
||||
command.ShowClock,
|
||||
command.AnalogFilterStrength
|
||||
);
|
||||
return Result.Success();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user