将Flipper中的page页号换成start记录号,将影响到HttpServlet中findFlipper的实现
This commit is contained in:
@@ -19,6 +19,7 @@ import javax.sql.ConnectionPoolDataSource;
|
||||
import javax.xml.stream.*;
|
||||
import static org.redkale.source.FilterNode.formatToString;
|
||||
import org.redkale.util.*;
|
||||
import static org.redkale.source.FilterNode.formatToString;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -1697,10 +1698,10 @@ public final class DataDefaultSource implements DataSource, Function<Class, Enti
|
||||
final String sql = "SELECT a.* FROM " + info.getTable() + " a" + (join == null ? "" : join)
|
||||
+ ((where == null || where.length() == 0) ? "" : (" WHERE " + where)) + info.createSQLOrderby(flipper);
|
||||
if (debug.get() && info.isLoggable(Level.FINEST))
|
||||
logger.finest(clazz.getSimpleName() + " query sql=" + sql + (flipper == null ? "" : (" LIMIT " + flipper.index() + "," + flipper.getSize())));
|
||||
logger.finest(clazz.getSimpleName() + " query sql=" + sql + (flipper == null ? "" : (" LIMIT " + flipper.getStart() + "," + flipper.getSize())));
|
||||
final PreparedStatement ps = conn.prepareStatement(sql, ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
|
||||
final ResultSet set = ps.executeQuery();
|
||||
if (flipper != null && flipper.index() > 0) set.absolute(flipper.index());
|
||||
if (flipper != null && flipper.getStart() > 0) set.absolute(flipper.getStart());
|
||||
final int limit = flipper == null ? Integer.MAX_VALUE : flipper.getSize();
|
||||
int i = 0;
|
||||
while (set.next()) {
|
||||
|
||||
@@ -302,7 +302,7 @@ public final class EntityCache<T> {
|
||||
Stream<T> stream = this.list.stream();
|
||||
if (filter != null) stream = stream.filter(filter);
|
||||
if (comparator != null) stream = stream.sorted(comparator);
|
||||
if (flipper != null) stream = stream.skip(flipper.index()).limit(flipper.getSize());
|
||||
if (flipper != null) stream = stream.skip(flipper.getStart()).limit(flipper.getSize());
|
||||
final List<T> rs = new ArrayList<>();
|
||||
if (selects == null) {
|
||||
Consumer<? super T> action = x -> rs.add(needcopy ? newReproduce.copy(creator.create(), x) : x);
|
||||
|
||||
@@ -20,7 +20,7 @@ public final class Flipper implements Serializable, Cloneable {
|
||||
|
||||
private int size = DEFAULT_PAGESIZE;
|
||||
|
||||
private int page = 1;
|
||||
private int start = 0;
|
||||
|
||||
private String sort = "";
|
||||
|
||||
@@ -35,49 +35,49 @@ public final class Flipper implements Serializable, Cloneable {
|
||||
this.sort = sortColumn;
|
||||
}
|
||||
|
||||
public Flipper(int pageSize, int pageNo) {
|
||||
public Flipper(int pageSize, int startIndex) {
|
||||
this.size = pageSize > 0 ? pageSize : DEFAULT_PAGESIZE;
|
||||
this.page = pageNo > 0 ? pageNo : 1;
|
||||
this.start = startIndex < 0 ? 0 : startIndex;
|
||||
}
|
||||
|
||||
public Flipper(int pageSize, int pageNo, String sortColumn) {
|
||||
public Flipper(int pageSize, int startIndex, String sortColumn) {
|
||||
this.size = pageSize > 0 ? pageSize : DEFAULT_PAGESIZE;
|
||||
this.page = pageNo > 0 ? pageNo : 1;
|
||||
this.start = startIndex < 0 ? 0 : startIndex;
|
||||
this.sort = sortColumn;
|
||||
}
|
||||
|
||||
public void copyTo(Flipper copy) {
|
||||
if (copy == null) return;
|
||||
copy.page = this.page;
|
||||
copy.start = this.start;
|
||||
copy.size = this.size;
|
||||
copy.sort = this.sort;
|
||||
}
|
||||
|
||||
public void copyFrom(Flipper copy) {
|
||||
if (copy == null) return;
|
||||
this.page = copy.page;
|
||||
this.start = copy.start;
|
||||
this.size = copy.size;
|
||||
this.sort = copy.sort;
|
||||
}
|
||||
|
||||
public Flipper next() {
|
||||
this.page++;
|
||||
this.start = getStart() + this.size;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("CloneDoesntCallSuperClone")
|
||||
public Flipper clone() {
|
||||
return new Flipper(this.size, this.page, this.sort);
|
||||
return new Flipper(this.size, this.start, this.sort);
|
||||
}
|
||||
|
||||
public int index() {
|
||||
return (getPage() - 1) * getSize();
|
||||
public int getStart() {
|
||||
return start;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return this.getClass().getSimpleName() + "{page:" + this.page + ", size=" + this.size + ", sort=" + this.sort + "}";
|
||||
return this.getClass().getSimpleName() + "{start:" + this.start + ", size=" + this.size + ", sort=" + this.sort + "}";
|
||||
}
|
||||
|
||||
public int getSize() {
|
||||
@@ -90,14 +90,8 @@ public final class Flipper implements Serializable, Cloneable {
|
||||
}
|
||||
}
|
||||
|
||||
public int getPage() {
|
||||
return page;
|
||||
}
|
||||
|
||||
public void setPage(int page) {
|
||||
if (page >= 0) {
|
||||
this.page = page;
|
||||
}
|
||||
public void setStart(int start) {
|
||||
this.start = start < 0 ? 0 : start;
|
||||
}
|
||||
|
||||
public String getSort() {
|
||||
|
||||
Reference in New Issue
Block a user