Merge remote-tracking branch 'origin/main' into feat/multi-rerun-collections-api
# Conflicts: # docs/blazor-route-parity.md # docs/endpoint-index.md
This commit is contained in:
@@ -2,6 +2,7 @@ using System.ComponentModel.DataAnnotations;
|
||||
using ErsatzTV.Application.MediaCollections;
|
||||
using ErsatzTV.Controllers.Api.Requests;
|
||||
using ErsatzTV.Core;
|
||||
using ErsatzTV.Core.Api.LibraryBrowse;
|
||||
using ErsatzTV.Extensions;
|
||||
using MediatR;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
@@ -32,6 +33,28 @@ public class CollectionController(IMediator mediator) : ControllerBase
|
||||
return result.ToGetResult();
|
||||
}
|
||||
|
||||
[HttpGet("/api/collections/{id:int}/items", Name = "GetCollectionItems")]
|
||||
[Tags("Collections")]
|
||||
[EndpointSummary("Get the items in a manual collection")]
|
||||
[EndpointDescription("Returns a manual collection's full contents (all media kinds), paged.")]
|
||||
[EndpointGroupName("general")]
|
||||
[ProducesResponseType(typeof(PagedLibraryBrowseItemsResponseModel), StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(typeof(ProblemDetails), StatusCodes.Status404NotFound)]
|
||||
public async Task<IActionResult> GetItems(
|
||||
int id,
|
||||
[FromQuery] int pageNum = 0,
|
||||
[FromQuery] int pageSize = 100,
|
||||
CancellationToken cancellationToken = default)
|
||||
{
|
||||
int clampedPageNum = Math.Max(0, pageNum);
|
||||
int clampedPageSize = Math.Clamp(pageSize, 1, 100);
|
||||
|
||||
Either<BaseError, PagedLibraryBrowseItemsResponseModel> result = await mediator.Send(
|
||||
new GetCollectionItems(id, clampedPageNum, clampedPageSize),
|
||||
cancellationToken);
|
||||
return result.ToUpdatedResult();
|
||||
}
|
||||
|
||||
[HttpPost("/api/collections")]
|
||||
[Tags("Collections")]
|
||||
[EndpointSummary("Create a collection")]
|
||||
|
||||
Reference in New Issue
Block a user