Files
ersatztv/ErsatzTV/Controllers/Api/PlaylistController.cs
T
timothyandClaude Fable 5 57bb320af8 feat(api): REST endpoints for decos, deco groups, playout default deco (#144 S3 (#162))
Adds DecoController (groups + decos CRUD + full-state PUT), playlist and
artist/multi-collection search picker wrappers, a PlaylistController for the
break-content playlist cascade, and PUT /api/playouts/{id}/deco. Fixes the
CreateDecoHandler missing deco-group existence check (FK 500 -> 422), matching
the CreateBlock/CreateTemplate precedent. ReplaceDecoRequest.ToCommand rejects
Merge on the non-mergeable sections (422).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-07 19:22:39 +02:00

38 lines
1.6 KiB
C#

using ErsatzTV.Application.MediaCollections;
using ErsatzTV.Core.Api.MediaCollections;
using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
namespace ErsatzTV.Controllers.Api;
[ApiController]
public class PlaylistController(IMediator mediator) : ControllerBase
{
[HttpGet("/api/playlists/groups", Name = "GetPlaylistGroups")]
[Tags("Playlists")]
[EndpointSummary("Get all playlist groups")]
[EndpointGroupName("general")]
[ProducesResponseType(typeof(List<PlaylistGroupResponseModel>), StatusCodes.Status200OK)]
public async Task<List<PlaylistGroupResponseModel>> GetGroups(CancellationToken cancellationToken)
{
List<PlaylistGroupViewModel> groups = await mediator.Send(new GetAllPlaylistGroups(), cancellationToken);
return groups.Map(g => new PlaylistGroupResponseModel(g.Id, g.Name, g.PlaylistCount, g.IsSystem)).ToList();
}
[HttpGet("/api/playlists", Name = "GetPlaylists")]
[Tags("Playlists")]
[EndpointSummary("Get playlists in a playlist group")]
[EndpointDescription("Returns the playlists in the given playlist group.")]
[EndpointGroupName("general")]
[ProducesResponseType(typeof(List<PlaylistResponseModel>), StatusCodes.Status200OK)]
public async Task<List<PlaylistResponseModel>> GetAll(
[FromQuery] int playlistGroupId,
CancellationToken cancellationToken)
{
List<PlaylistViewModel> playlists =
await mediator.Send(new GetPlaylistsByPlaylistGroupId(playlistGroupId), cancellationToken);
return playlists.Map(p => new PlaylistResponseModel(p.Id, p.PlaylistGroupId, p.Name, p.IsSystem)).ToList();
}
}