-
Notifications
You must be signed in to change notification settings - Fork 3
/
api-option.go
55 lines (45 loc) · 857 Bytes
/
api-option.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
package weiyunsdkgo
type ParamOption func(Json)
func WarpParamOption(option ...ParamOption) []ParamOption {
return option
}
func ApplyParamOption(param Json, option ...ParamOption) Json {
for _, opt := range option {
opt(param)
}
return param
}
func QueryFileOptionCount(size int) ParamOption {
return func(j Json) {
j["count"] = size
}
}
type OrderBy int8
const (
_ OrderBy = iota
FileName
FileMtime
FileSize
)
func QueryFileOptionSort(orderBy OrderBy, desc bool) ParamOption {
return func(j Json) {
j["sort_field"] = orderBy
j["reverse_order"] = desc
}
}
type GetType int8
const (
FileAndDir = iota
OnlyDir
OnlyFile
)
func QueryFileOptionGetType(t GetType) ParamOption {
return func(j Json) {
j["get_type"] = t
}
}
func QueryFileOptionOffest(start int64) ParamOption {
return func(j Json) {
j["start"] = start
}
}