| | |
| | | * @author |
| | | * @since |
| | | */ |
| | | public interface IPageVO<T> extends Serializable { |
| | | public class IPageVO<T> implements Serializable { |
| | | |
| | | /** |
| | | * 获取排序信息,排序的字段和正反序 |
| | | * |
| | | * @return 排序信息 |
| | | */ |
| | | List<Object> orders(); |
| | | List<Object> orders(){return null;} |
| | | |
| | | /** |
| | | * KEY/VALUE 条件 |
| | |
| | | * @deprecated 3.4.0 @2020-06-30 |
| | | */ |
| | | @Deprecated |
| | | default Map<Object, Object> condition() { |
| | | Map<Object, Object> condition() { |
| | | return null; |
| | | } |
| | | |
| | |
| | | * |
| | | * @return true 是 / false 否 |
| | | */ |
| | | default boolean optimizeCountSql() { |
| | | boolean optimizeCountSql() { |
| | | return true; |
| | | } |
| | | |
| | |
| | | * |
| | | * @return true 是 / false 否 |
| | | */ |
| | | default boolean isSearchCount() { |
| | | boolean isSearchCount() { |
| | | return true; |
| | | } |
| | | |
| | | /** |
| | | * 计算当前分页偏移量 |
| | | */ |
| | | default long offset() { |
| | | long offset() { |
| | | long current = getCurrent(); |
| | | if (current <= 1L) { |
| | | return 0L; |
| | |
| | | * |
| | | * @since 3.4.0 @2020-07-17 |
| | | */ |
| | | default Long maxLimit() { |
| | | Long maxLimit() { |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * 当前分页总页数 |
| | | */ |
| | | default long getPages() { |
| | | long getPages() { |
| | | if (getSize() == 0) { |
| | | return 0L; |
| | | } |
| | |
| | | * 内部什么也不干 |
| | | * <p>只是为了 json 反序列化时不报错</p> |
| | | */ |
| | | default IPageVO<T> setPages(long pages) { |
| | | IPageVO<T> setPages(long pages) { |
| | | // to do nothing |
| | | return this; |
| | | } |
| | |
| | | * @deprecated 3.4.0 @2020-06-30 缓存遵循mybatis的一或二缓 |
| | | */ |
| | | @Deprecated |
| | | default void hitCount(boolean hit) { |
| | | void hitCount(boolean hit) { |
| | | |
| | | } |
| | | |
| | |
| | | * @deprecated 3.4.0 @2020-06-30 缓存遵循mybatis的一或二缓 |
| | | */ |
| | | @Deprecated |
| | | default boolean isHitCount() { |
| | | boolean isHitCount() { |
| | | return false; |
| | | } |
| | | |
| | |
| | | * |
| | | * @return 分页对象记录列表 |
| | | */ |
| | | List<T> getRecords(); |
| | | List<T> getRecords(){return null;} |
| | | |
| | | /** |
| | | * 设置分页记录列表 |
| | | */ |
| | | IPageVO<T> setRecords(List<T> records); |
| | | IPageVO<T> setRecords(List<T> records){return null;} |
| | | |
| | | /** |
| | | * 当前满足条件总行数 |
| | | * |
| | | * @return 总条数 |
| | | */ |
| | | long getTotal(); |
| | | long getTotal(){return 0l;} |
| | | |
| | | /** |
| | | * 设置当前满足条件总行数 |
| | | */ |
| | | IPageVO<T> setTotal(long total); |
| | | IPageVO<T> setTotal(long total){return null;} |
| | | |
| | | /** |
| | | * 获取每页显示条数 |
| | | * |
| | | * @return 每页显示条数 |
| | | */ |
| | | long getSize(); |
| | | long getSize(){return 0;} |
| | | |
| | | /** |
| | | * 设置每页显示条数 |
| | | */ |
| | | IPageVO<T> setSize(long size); |
| | | IPageVO<T> setSize(long size){return null;} |
| | | |
| | | /** |
| | | * 当前页 |
| | | * |
| | | * @return 当前页 |
| | | */ |
| | | long getCurrent(); |
| | | long getCurrent(){return 0l;} |
| | | |
| | | /** |
| | | * 设置当前页 |
| | | */ |
| | | IPageVO<T> setCurrent(long current); |
| | | IPageVO<T> setCurrent(long current){return null;} |
| | | |
| | | /** |
| | | * IPageVO 的泛型转换 |
| | |
| | | * @return 转换泛型后的 IPageVO |
| | | */ |
| | | @SuppressWarnings("unchecked") |
| | | default <R> IPageVO<R> convert(Function<? super T, ? extends R> mapper) { |
| | | <R> IPageVO<R> convert(Function<? super T, ? extends R> mapper) { |
| | | List<R> collect = this.getRecords().stream().map(mapper).collect(toList()); |
| | | return ((IPageVO<R>) this).setRecords(collect); |
| | | } |
| | |
| | | * @return id |
| | | * @since 3.4.0 @2020-06-19 |
| | | */ |
| | | default String countId() { |
| | | String countId() { |
| | | return null; |
| | | } |
| | | |