package com.liangjian.dataplatform.member.util;

import com.liangjian.dataplatform.member.entity.response.PageResult;
import org.springframework.data.domain.Page;

import java.util.List;

/**
 * @Author: 黄子奇
 * @Date: 2019/8/28 11:24
 *
 * 用于将jpa自带的Page转换成PageResult的工具类
 */
public class PageTransfer {

    public static <T> PageResult<T> transfer(Page<T> jpaPage) {
        Long total = jpaPage.getTotalElements();
        List<T> items = jpaPage.getContent();
        return PageResult.success(items,total);
    }
}
