Kavita/API/Helpers/UserParams.cs
Joe Milazzo 9f29fa593d
Progress Overhaul + Profile Page and a LOT more! (#4262)
Co-authored-by: Amelia <77553571+Fesaa@users.noreply.github.com>
Co-authored-by: Robbie Davis <robbie@therobbiedavis.com>
2025-12-09 10:00:11 -07:00

31 lines
920 B
C#

namespace API.Helpers;
#nullable enable
/// <summary>
/// User params should be used together with [FromQuery] to add optional pagination to endpoint. If no pagination params are
/// provided, the default (int.MaxValue) will be used. When adding pagination to an endpoint, ensure the UI sets the correct
/// query params.
/// </summary>
/// <remarks>[FromQuery] always assigns the object, it'll never return null</remarks>
public class UserParams
{
private const int MaxPageSize = int.MaxValue;
public int PageNumber { get; init; } = 1;
private readonly int _pageSize = MaxPageSize;
/// <summary>
/// If set to 0, will set as MaxInt
/// </summary>
public int PageSize
{
get => _pageSize;
init => _pageSize = (value == 0) ? MaxPageSize : value;
}
public static readonly UserParams Default = new()
{
PageSize = 20,
PageNumber = 1,
};
}