/
options.go
66 lines (48 loc) · 1.06 KB
/
options.go
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
package countable
import (
"github.com/aaronland/go-pagination"
)
const PER_PAGE int64 = 10
const PAGE int64 = 1
const SPILL int64 = 2
const COUNTABLE string = "*"
type CountablePaginationOptions struct {
pagination.PaginationOptions
perpage int64
page int64
spill int64
column string
}
func NewCountablePaginationOptions() (pagination.PaginationOptions, error) {
opts := &CountablePaginationOptions{
perpage: PER_PAGE,
page: PAGE,
spill: SPILL,
column: COUNTABLE,
}
return opts, nil
}
func (opts *CountablePaginationOptions) PerPage(args ...int64) int64 {
if len(args) >= 1 {
opts.perpage = args[0]
}
return opts.perpage
}
func (opts *CountablePaginationOptions) Page(args ...int64) int64 {
if len(args) >= 1 {
opts.page = args[0]
}
return opts.page
}
func (opts *CountablePaginationOptions) Spill(args ...int64) int64 {
if len(args) >= 1 {
opts.spill = args[0]
}
return opts.spill
}
func (opts *CountablePaginationOptions) Column(args ...string) string {
if len(args) >= 1 {
opts.column = args[0]
}
return opts.column
}