| | |
| | | package com.vci.rmip.code.client.codeapply.Apply410.object; |
| | | |
| | | import java.io.Serializable; |
| | | import java.util.List; |
| | | import java.util.function.Function; |
| | | import java.util.stream.Collectors; |
| | | |
| | | public interface IPage<T> extends Serializable { |
| | | List<OrderItem> orders(); |
| | | |
| | | default boolean optimizeCountSql() { |
| | | return true; |
| | | } |
| | | // default boolean optimizeCountSql() { |
| | | // return true; |
| | | // } |
| | | |
| | | default boolean optimizeJoinOfCountSql() { |
| | | return true; |
| | | } |
| | | // default boolean optimizeJoinOfCountSql() { |
| | | // return true; |
| | | // } |
| | | // |
| | | // default boolean searchCount() { |
| | | // return true; |
| | | // } |
| | | // |
| | | // default long offset() { |
| | | // long current = this.getCurrent(); |
| | | // return current <= 1L ? 0L : Math.max((current - 1L) * this.getSize(), 0L); |
| | | // } |
| | | |
| | | default boolean searchCount() { |
| | | return true; |
| | | } |
| | | // default Long maxLimit() { |
| | | // return null; |
| | | // } |
| | | // |
| | | // default long getPages() { |
| | | // if (this.getSize() == 0L) { |
| | | // return 0L; |
| | | // } else { |
| | | // long pages = this.getTotal() / this.getSize(); |
| | | // if (this.getTotal() % this.getSize() != 0L) { |
| | | // ++pages; |
| | | // } |
| | | // |
| | | // return pages; |
| | | // } |
| | | // } |
| | | |
| | | default long offset() { |
| | | long current = this.getCurrent(); |
| | | return current <= 1L ? 0L : Math.max((current - 1L) * this.getSize(), 0L); |
| | | } |
| | | |
| | | default Long maxLimit() { |
| | | return null; |
| | | } |
| | | |
| | | default long getPages() { |
| | | if (this.getSize() == 0L) { |
| | | return 0L; |
| | | } else { |
| | | long pages = this.getTotal() / this.getSize(); |
| | | if (this.getTotal() % this.getSize() != 0L) { |
| | | ++pages; |
| | | } |
| | | |
| | | return pages; |
| | | } |
| | | } |
| | | |
| | | default IPage<T> setPages(long pages) { |
| | | return this; |
| | | } |
| | | // default IPage<T> setPages(long pages) { |
| | | // return this; |
| | | // } |
| | | |
| | | List<T> getRecords(); |
| | | |
| | |
| | | |
| | | IPage<T> setCurrent(long current); |
| | | |
| | | default <R> IPage<T> convert(Function<? super T, ? extends R> mapper) { |
| | | List<T> collect = (List)this.getRecords().stream().map(mapper).collect(Collectors.toList()); |
| | | return this.setRecords(collect); |
| | | } |
| | | default String countId() { |
| | | return null; |
| | | } |
| | | // default <R> IPage<T> convert(Function<? super T, ? extends R> mapper) { |
| | | // List<T> collect = (List)this.getRecords().stream().map(mapper).collect(Collectors.toList()); |
| | | // return this.setRecords(collect); |
| | | // } |
| | | // default String countId() { |
| | | // return null; |
| | | // } |
| | | } |