shz.spring.model.PageVo Maven / Gradle / Ivy
package shz.spring.model;
import shz.core.model.PageInfo;
import java.util.function.Function;
public class PageVo extends RequestVo {
private Integer page;
private Integer size;
private Integer current;
private O currentFirst;
private O currentLast;
private Integer pageNum;
private Integer pageSize;
public Integer getPage() {
return page;
}
public void setPage(Integer page) {
this.page = page;
}
public Integer getSize() {
return size;
}
public void setSize(Integer size) {
this.size = size;
}
public Integer getCurrent() {
return current;
}
public void setCurrent(Integer current) {
this.current = current;
}
public O getCurrentFirst() {
return currentFirst;
}
public void setCurrentFirst(O currentFirst) {
this.currentFirst = currentFirst;
}
public O getCurrentLast() {
return currentLast;
}
public void setCurrentLast(O currentLast) {
this.currentLast = currentLast;
}
public Integer getPageNum() {
return pageNum;
}
public void setPageNum(Integer pageNum) {
this.pageNum = pageNum;
}
public Integer getPageSize() {
return pageSize;
}
public void setPageSize(Integer pageSize) {
this.pageSize = pageSize;
}
@Override
public String toString() {
return "PageVo{" +
"page=" + page +
", size=" + size +
", current=" + current +
", currentFirst=" + currentFirst +
", currentLast=" + currentLast +
", pageNum=" + pageNum +
", pageSize=" + pageSize +
"} " + super.toString();
}
public PageInfo simple() {
PageInfo pageInfo = PageInfo.of(page != null ? page : pageNum != null ? pageNum : 1, size != null ? size : pageSize != null ? pageSize : 10);
pageInfo.setCurrent(current == null ? 0 : current);
return pageInfo;
}
public PageInfo map(Function super O, ? extends T> mapper) {
PageInfo pageInfo = simple();
if (currentFirst != null) pageInfo.setCurrentFirst(mapper.apply(currentFirst));
if (currentLast != null) pageInfo.setCurrentLast(mapper.apply(currentLast));
return pageInfo;
}
@SuppressWarnings("unchecked")
public PageInfo map() {
return map(o -> (T) o);
}
public static PageVo max(I data) {
PageVo pageVo = new PageVo<>();
pageVo.setSize(Integer.MAX_VALUE);
pageVo.setData(data);
return pageVo;
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy