initial upload
This commit is contained in:
parent
a0aa9cc28e
commit
f857f43df4
553 changed files with 46169 additions and 13 deletions
49
src/Core/Insight.Infrastructure/Models/Pagination.cs
Normal file
49
src/Core/Insight.Infrastructure/Models/Pagination.cs
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Insight.Infrastructure.Models
|
||||
{
|
||||
public class PagedList<T>
|
||||
{
|
||||
public PagedMetaData Meta { get; } = new();
|
||||
public IEnumerable<T> Data { get; }
|
||||
|
||||
public PagedList(IEnumerable<T> data, int offset, int limit, long total)
|
||||
{
|
||||
Data = data;
|
||||
Meta = new()
|
||||
{
|
||||
Offset = offset,
|
||||
Limit = limit,
|
||||
Count = data?.Count() ?? 0,
|
||||
Total = total,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
public class PagedDataRequest
|
||||
{
|
||||
[JsonPropertyName("offset")]
|
||||
public int Offset { get; set; } = 0;
|
||||
|
||||
[JsonPropertyName("limit")]
|
||||
public int Limit { get; set; } = 10;
|
||||
}
|
||||
|
||||
public class PagedHeaderData : PagedDataRequest
|
||||
{
|
||||
[JsonPropertyName("count")]
|
||||
public int Count { get; set; } = 0;
|
||||
|
||||
[JsonPropertyName("total")]
|
||||
public long Total { get; set; } = 0;
|
||||
}
|
||||
|
||||
public class PagedMetaData : PagedHeaderData
|
||||
{
|
||||
[JsonPropertyName("next")]
|
||||
public string? Next { get; set; }
|
||||
|
||||
[JsonPropertyName("previous")]
|
||||
public string? Previous { get; set; }
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue