package com.vaessl.app.search;

import java.util.List;
import org.springframework.data.domain.Page;

public record PagedSearchResponse<T>(List<T> content, int page, int pageSize, long totalElements,
        boolean first, boolean last, String sort, String summary) {

    public static <T> PagedSearchResponse<T> from(Page<T> pageResult) {
        return new PagedSearchResponse<>(pageResult.getContent(), pageResult.getNumber(),
                pageResult.getSize(), pageResult.getTotalElements(), pageResult.isFirst(),
                pageResult.isLast(), pageResult.getSort().toString(), null);
    }
}
