added pagination controls
All checks were successful
Build and Push Image / build-and-push (push) Successful in 4m33s
All checks were successful
Build and Push Image / build-and-push (push) Successful in 4m33s
This commit is contained in:
@@ -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; }
|
||||
}
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user