package com.agent.management.model.vo;

import lombok.Data;

import java.util.List;

/**
 * 分页结果包装
 */
@Data
public class PageResult<T> {

    private List<T> content;
    private long total;
    private int page;
    private int size;
    private int totalPages;

    public static <T> PageResult<T> of(List<T> content, long total, int page, int size) {
        PageResult<T> result = new PageResult<>();
        result.setContent(content);
        result.setTotal(total);
        result.setPage(page);
        result.setSize(size);
        result.setTotalPages(size > 0 ? (int) Math.ceil((double) total / size) : 0);
        return result;
    }
}
