其他分享
首页 > 其他分享> > dsl查询queryResults转page

dsl查询queryResults转page

作者:互联网

    private static final long serialVersionUID = 1L;
    //元素内容
    private List<T> content;
    //是否有上一页
    private boolean first;
    //是否有下一页
    private boolean last;
    //当前页
    private int number;
    //当页条数
    private int numberOfElements;
    //页大小
    private int size;
    //总条数
    private long totalElements;
    //总页数
    private int totalPages;


        QueryResults<Customer> customerQueryResultsPageable = limit.fetchResults();

        System.out.println(customerQueryResultsPageable.getResults());
        System.out.println("限制(每页条数):"+customerQueryResultsPageable.getLimit());
        System.out.println("总数:"+customerQueryResultsPageable.getTotal());
        System.out.println("跳过:"+customerQueryResultsPageable.getOffset());



   public RestPage(QueryResults queryResults) {

        //当前页
        long currenPage = queryResults.getOffset()/queryResults.getLimit();

        //总页数
        long PageCount = queryResults.getTotal()%queryResults.getLimit() == 0?queryResults.getTotal()/queryResults.getLimit():queryResults.getTotal()/queryResults.getLimit()+1;

        //是否有上一页
        Boolean queryResultsIsFirst = currenPage==0?false:true;
        //是否有下一页
        Boolean queryResultsIsLast = currenPage+1<PageCount?true:false;

        this.content = queryResults.getResults();
        this.first = queryResultsIsFirst;
        this.last = queryResultsIsLast;
        this.number = (int)currenPage;
        this.numberOfElements = queryResults.getResults().size();
        this.size = (int)queryResults.getLimit();
        this.totalElements = queryResults.getTotal();
        this.totalPages = (int)PageCount;
    }

标签:int,dsl,private,customerQueryResultsPageable,queryResults,long,getLimit,page
来源: https://www.cnblogs.com/Arborblog/p/16631815.html