com.github.aqiu202.starters.jpa.page.JPAPageResult Maven / Gradle / Ivy
package com.github.aqiu202.starters.jpa.page;
import com.noah.base.page.PageResult;
import com.noah.base.page.PageableInput;
import com.querydsl.core.QueryResults;
import java.util.List;
import org.springframework.data.domain.Page;
public class JPAPageResult extends PageResult {
private JPAPageResult(List rows, long total) {
super(rows, total);
}
public static PageResult of(Page page, PageableInput pageable) {
return of(page).pageable(pageable);
}
public static PageResult of(QueryResults page, PageableInput pageable) {
return of(page).pageable(pageable);
}
public static PageResult of(Page page) {
return of(page.getContent(), page.getTotalElements());
}
public static PageResult of(QueryResults page) {
return of(page.getResults(), page.getTotal());
}
}