com.midcu.common.web.qo.PageQuery Maven / Gradle / Ivy
The newest version!
package com.midcu.common.web.qo;
import com.baomidou.mybatisplus.core.metadata.OrderItem;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.Data;
import java.util.ArrayList;
import java.util.List;
@Data
public class PageQuery {
private long size = 10;
private long current = 1;
private List orders = new ArrayList<>();
public long getPageCurrent() {
return current - 1 < 0 ? 0 : current - 1;
}
public static PageQuery of(long current, long size, List orders) {
PageQuery query = new PageQuery();
query.setCurrent(current);
query.setSize(size);
query.setOrders(orders);
return query;
}
public Page build() {
Page page = Page.of(current, size);
if (orders != null && orders.size() > 0) {
page.setOrders(orders);
}
return Page.of(current, size);
}
}