PagedResp.java 1.19 KB
package com.glsx.common.pojo;

import java.util.List;
import com.glsx.common.utils.Page;

/**
 * <p>Description: 分页查询的通用结果
 *
 * <p>Project: car-service
 *
 * @author wbh
 * @date 2020-05-22
 */
public class PagedResp<E> {
    private Page page;
    private List<E> items;

    private PagedResp(Page page, List<E> items) {
        this.page = page;
        this.items = items;
    }

    public static <E> PagedResp<E> of(long totalCount, PagedReq orderReq, List<E> list) {

        Page page = new Page(orderReq.getPageIndex(), orderReq.getPageSize());
        page.setTotalCount((int) totalCount);

        return of(page, list);
    }

    public static <E> PagedResp<E> of(Page page, List<E> list) {
        return new PagedResp<>(page, list);
    }

    public Page getPage() {
        return this.page;
    }

    public void setPage(Page page) {
        this.page = page;
    }

    public List<E> getItems() {
        return this.items;
    }

    public void setItems(List<E> items) {
        this.items = items;
    }

    @Override
    public String toString() {
        return "PagedResp{" +
            "page=" + this.page +
            ", items=" + this.items +
            '}';
    }
}