Add bumper variant management: implement API endpoints for adding, updating, and removing bumper text variants, enhance data models to support variant details, and update scheduling logic to utilize variants. Refactor related components for improved bumper template handling and ensure proper error management for variant operations.
This commit is contained in:
@@ -93,6 +93,22 @@ public static class ChannelEndpoints
|
||||
PreviewSegment
|
||||
);
|
||||
|
||||
admin
|
||||
.MapPost("/{id:guid}/bumper/templates/{templateId:guid}/variants", AddBumperVariant)
|
||||
.Produces<CreatedIdResponse>(StatusCodes.Status201Created);
|
||||
admin
|
||||
.MapPut(
|
||||
"/{id:guid}/bumper/templates/{templateId:guid}/variants/{variantId:guid}",
|
||||
UpdateBumperVariant
|
||||
)
|
||||
.Produces(StatusCodes.Status204NoContent);
|
||||
admin
|
||||
.MapDelete(
|
||||
"/{id:guid}/bumper/templates/{templateId:guid}/variants/{variantId:guid}",
|
||||
RemoveBumperVariant
|
||||
)
|
||||
.Produces(StatusCodes.Status204NoContent);
|
||||
|
||||
admin
|
||||
.MapPost("/{id:guid}/overrides", CreateOverride)
|
||||
.Produces<CreatedIdResponse>(StatusCodes.Status201Created);
|
||||
@@ -348,6 +364,65 @@ public static class ChannelEndpoints
|
||||
return result.ToHttpResult();
|
||||
}
|
||||
|
||||
private static async Task<IResult> AddBumperVariant(
|
||||
Guid id,
|
||||
Guid templateId,
|
||||
AddBumperVariantBody body,
|
||||
ISender sender,
|
||||
CancellationToken cancellationToken
|
||||
)
|
||||
{
|
||||
var result = await sender.Send(
|
||||
new AddBumperTextVariantCommand(id, templateId, body.Name),
|
||||
cancellationToken
|
||||
);
|
||||
return result.IsSuccess
|
||||
? Results.Created($"/api/admin/channels/{id}", new CreatedIdResponse(result.Value))
|
||||
: result.ToHttpResult();
|
||||
}
|
||||
|
||||
private static async Task<IResult> UpdateBumperVariant(
|
||||
Guid id,
|
||||
Guid templateId,
|
||||
Guid variantId,
|
||||
UpdateBumperVariantBody body,
|
||||
ISender sender,
|
||||
CancellationToken cancellationToken
|
||||
)
|
||||
{
|
||||
var result = await sender.Send(
|
||||
new UpdateBumperTextVariantCommand(
|
||||
id,
|
||||
templateId,
|
||||
variantId,
|
||||
body.Name,
|
||||
body.Kind,
|
||||
body.NowLabel,
|
||||
body.NextLabel,
|
||||
body.Line1,
|
||||
body.Line2,
|
||||
body.Trigger
|
||||
),
|
||||
cancellationToken
|
||||
);
|
||||
return result.ToHttpResult();
|
||||
}
|
||||
|
||||
private static async Task<IResult> RemoveBumperVariant(
|
||||
Guid id,
|
||||
Guid templateId,
|
||||
Guid variantId,
|
||||
ISender sender,
|
||||
CancellationToken cancellationToken
|
||||
)
|
||||
{
|
||||
var result = await sender.Send(
|
||||
new RemoveBumperTextVariantCommand(id, templateId, variantId),
|
||||
cancellationToken
|
||||
);
|
||||
return result.ToHttpResult();
|
||||
}
|
||||
|
||||
private static async Task<IResult> ClearTemplateBackground(
|
||||
Guid id,
|
||||
Guid templateId,
|
||||
@@ -532,6 +607,18 @@ public sealed record AddBumperTemplateBody(string Name);
|
||||
|
||||
public sealed record SetBumperTemplateBackgroundBody(Guid ImageId);
|
||||
|
||||
public sealed record AddBumperVariantBody(string Name);
|
||||
|
||||
public sealed record UpdateBumperVariantBody(
|
||||
string Name,
|
||||
BumperTextKind Kind,
|
||||
string NowLabel,
|
||||
string NextLabel,
|
||||
string Line1,
|
||||
string Line2,
|
||||
BumperTrigger Trigger
|
||||
);
|
||||
|
||||
public sealed record UpdateBumperTemplateBody(
|
||||
string Name,
|
||||
string BackgroundColor,
|
||||
|
||||
Reference in New Issue
Block a user