xiejun
2023-08-02 8b34692ac1b7cf58a1e1ead92b930d9acb9f86f6
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
package com.vci.ubcs.codeapply.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 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 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;
    }
 
    List<T> getRecords();
 
    IPage<T> setRecords(List<T> records);
 
    long getTotal();
 
    IPage<T> setTotal(long total);
 
    long getSize();
 
    IPage<T> setSize(long size);
 
    long getCurrent();
 
    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;
    }
}