added pagination controls
All checks were successful
Build and Push Image / build-and-push (push) Successful in 4m33s

This commit is contained in:
2025-12-28 14:29:46 -05:00
parent 21163b277d
commit 41aa78b672
13 changed files with 107 additions and 28 deletions

View File

@@ -5,13 +5,13 @@ using System.Text;
using System.Threading.Tasks;
namespace AobaCore.Models;
public class PagedResult<T>(List<T> items, int page, int pageSize, long totalItems)
public class PagedResult<T>(List<T> items, int page, int pageSize, int totalItems)
{
public List<T> Items { get; set; } = items;
public int Page { get; set; } = page;
public int PageSize { get; set; } = pageSize;
public long TotalItems { get; set; } = totalItems;
public long TotalPages { get; set; } = totalItems / pageSize;
public int TotalItems { get; set; } = totalItems;
public int TotalPages { get; set; } = (totalItems / pageSize) + 1;
public string? Query { get; set; }
}

View File

@@ -37,7 +37,7 @@ public class AobaService(IMongoDatabase db)
var total = await find.CountDocumentsAsync();
page -= 1;
var items = await find.Sort(sort).Skip(page * pageSize).Limit(pageSize).ToListAsync();
return new PagedResult<Media>(items, page, pageSize, total);
return new PagedResult<Media>(items, page, pageSize, (int)total);
}
public async Task<List<Media>> FindMediaWithExtAsync(string ext, CancellationToken cancellationToken = default)