package com.yonge.cooleshow.biz.dal.dto;


import com.yonge.toolset.base.page.PageInfo;

import java.util.Objects;

/**
 * @author hgw
 * Created by 2021-12-03
 */
public class PageUtil {

    public static <T> PageInfo<T> pageInfo(com.microsvc.toolkit.common.response.paging.PageInfo<T> source) {
        if (Objects.isNull(source)) {
            return new PageInfo<>(1, 20);
        }
        int total = Integer.parseInt(String.valueOf(source.getTotal()));
        int limit = Integer.parseInt(String.valueOf(source.getLimit()));
        PageInfo<T> resultPage = new PageInfo<>();
        resultPage.setRows(source.getRows());
        resultPage.setPageNo(Long.valueOf(source.getCurrent()).intValue());
        resultPage.setLimit(limit);
        resultPage.setTotal(total);
        return resultPage;
    }
}
