namespace detect.gui.Models;

using System;
using System.Collections.Generic;

public class PagedResult<T>
{
    // 当前页码
    public int Current { get; set; }

    // 总页数
    public int Pages { get; set; }

    // 当前页的记录数据
    public List<T> Records { get; set; }

    // 每页的大小
    public int Size { get; set; }

    // 记录总数
    public int Total { get; set; }

    // 构造函数
    public PagedResult(int current, int size, int total, List<T> records)
    {
        Current = current;
        Size = size;
        Total = total;
        Records = records ?? new List<T>();

        // 自动计算总页数
        Pages = (int)Math.Ceiling(total / (double)size);
    }

    // 重写ToString方法便于展示分页信息
    public override string ToString()
    {
        return $"Page {Current}/{Pages}, Size: {Size}, Total Records: {Total}, Records Count: {Records.Count}";
    }
}
