Flipper优化
This commit is contained in:
@@ -164,7 +164,9 @@ public interface DataResultSet extends EntityInfo.DataResultSetRow {
|
|||||||
}
|
}
|
||||||
} else if (t == LocalDateTime.class) {
|
} else if (t == LocalDateTime.class) {
|
||||||
if (o != null && !(o instanceof LocalDateTime)) {
|
if (o != null && !(o instanceof LocalDateTime)) {
|
||||||
if (o instanceof java.sql.Timestamp) {
|
if (o instanceof java.sql.Date) {
|
||||||
|
o = ((java.sql.Date) o).toLocalDate().atStartOfDay();
|
||||||
|
} else if (o instanceof java.sql.Timestamp) {
|
||||||
o = ((java.sql.Timestamp) o).toLocalDateTime();
|
o = ((java.sql.Timestamp) o).toLocalDateTime();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,8 +7,8 @@ package org.redkale.source;
|
|||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import org.redkale.convert.ConvertColumn;
|
|
||||||
import org.redkale.annotation.Comment;
|
import org.redkale.annotation.Comment;
|
||||||
|
import org.redkale.convert.ConvertColumn;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 翻页对象, offset从0开始, limit必须大于0
|
* 翻页对象, offset从0开始, limit必须大于0
|
||||||
@@ -62,7 +62,9 @@ public final class Flipper implements Serializable, Cloneable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Flipper copyTo(Flipper copy) {
|
public Flipper copyTo(Flipper copy) {
|
||||||
if (copy == null) return copy;
|
if (copy == null) {
|
||||||
|
return copy;
|
||||||
|
}
|
||||||
copy.offset = this.offset;
|
copy.offset = this.offset;
|
||||||
copy.limit = this.limit;
|
copy.limit = this.limit;
|
||||||
copy.sort = this.sort;
|
copy.sort = this.sort;
|
||||||
@@ -70,18 +72,37 @@ public final class Flipper implements Serializable, Cloneable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Flipper copyFrom(Flipper copy) {
|
public Flipper copyFrom(Flipper copy) {
|
||||||
if (copy == null) return this;
|
if (copy == null) {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
this.offset = copy.offset;
|
this.offset = copy.offset;
|
||||||
this.limit = copy.limit;
|
this.limit = copy.limit;
|
||||||
this.sort = copy.sort;
|
this.sort = copy.sort;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 翻下一页
|
||||||
|
*
|
||||||
|
* @return Flipper
|
||||||
|
*/
|
||||||
public Flipper next() {
|
public Flipper next() {
|
||||||
this.offset = getOffset() + this.limit;
|
this.offset = getOffset() + this.limit;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置当前页号,页号从1开始
|
||||||
|
*
|
||||||
|
* @param current 页号, 从1开始
|
||||||
|
*
|
||||||
|
* @return Flipper
|
||||||
|
*/
|
||||||
|
public Flipper current(int current) {
|
||||||
|
this.offset = (current - 1) * this.limit;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@SuppressWarnings("CloneDoesntCallSuperClone")
|
@SuppressWarnings("CloneDoesntCallSuperClone")
|
||||||
public Flipper clone() {
|
public Flipper clone() {
|
||||||
@@ -90,7 +111,8 @@ public final class Flipper implements Serializable, Cloneable {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "{offset:" + this.offset + ",limit:" + this.limit + ((sort == null || sort.isEmpty()) ? "" : (",sort:\"" + this.sort.replace('"', '\'') + "\"")) + "}";
|
return "{offset:" + this.offset + ",limit:" + this.limit
|
||||||
|
+ ((sort == null || sort.isEmpty()) ? "" : (",sort:\"" + this.sort.replace('"', '\'') + "\"")) + "}";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -104,12 +126,22 @@ public final class Flipper implements Serializable, Cloneable {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object obj) {
|
public boolean equals(Object obj) {
|
||||||
if (this == obj) return true;
|
if (this == obj) {
|
||||||
if (obj == null) return false;
|
return true;
|
||||||
if (getClass() != obj.getClass()) return false;
|
}
|
||||||
|
if (obj == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (getClass() != obj.getClass()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
final Flipper other = (Flipper) obj;
|
final Flipper other = (Flipper) obj;
|
||||||
if (this.offset != other.offset) return false;
|
if (this.offset != other.offset) {
|
||||||
if (this.limit != other.limit) return false;
|
return false;
|
||||||
|
}
|
||||||
|
if (this.limit != other.limit) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
return Objects.equals(this.sort, other.sort);
|
return Objects.equals(this.sort, other.sort);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -163,7 +195,9 @@ public final class Flipper implements Serializable, Cloneable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static Flipper sortIfAbsent(Flipper flipper, String sort) {
|
public static Flipper sortIfAbsent(Flipper flipper, String sort) {
|
||||||
if (flipper != null) return flipper.sortIfAbsent(sort);
|
if (flipper != null) {
|
||||||
|
return flipper.sortIfAbsent(sort);
|
||||||
|
}
|
||||||
return flipper;
|
return flipper;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user