All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.yun.util.querydsl.PageBean Maven / Gradle / Ivy

There is a newer version: 0.0.31
Show newest version
package com.yun.util.querydsl;

import com.querydsl.core.QueryResults;

import java.util.List;

/**
 * @author: yun
 * @createdOn: 2019-02-28 18:54.
 */

public class PageBean {
    private final long current;
    private final long size;
    private final long total;
    private final long pages;
    private final List records;

    public PageBean(QueryResults rst) {
        long pI = rst.getOffset() / rst.getLimit();
        if (ParaUtil.isStartFromOne) {
            pI++;
        }

        current = pI;

        // todo 暂时处理
        size = rst.getLimit() == Long.MAX_VALUE ? 20 : rst.getLimit();

        total = rst.getTotal();

        records = rst.getResults();

        if (size > 0) {
            long page = total / size;
            if (total % size > 0) {
                page++;
            }

            pages = page;
        } else {
            pages = 0;
        }
    }

    public long getCurrent() {
        return current;
    }

    public long getSize() {
        return size;
    }

    public long getTotal() {
        return total;
    }

    public long getPages() {
        return pages;
    }

    public List getRecords() {
        return records;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy