data_table.go
999 字节
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
package domain
type DataTable struct {
Fields []*Field `json:"fields"`
Data [][]string `json:"data"`
Total int64 `json:"total"`
}
type Where struct {
PageNumber int `json:"pageNumber"`
PageSize int `json:"pageSize"`
Conditions []Condition `json:"conditions"`
}
func (w Where) Offset() int {
if w.PageNumber == 0 && w.PageSize == 0 {
return 0
}
return (w.PageNumber - 1) * w.PageSize
}
type Condition struct {
Field *Field `json:"field"`
Like string `json:"like"`
In []interface{} `json:"in"`
Ex []interface{} `json:"ex"`
Range []interface{} `json:"range"`
Order string `json:"order"`
}
func (t *DataTable) OptionalValue() []string {
var values = make([]string, 0)
if len(t.Data) > 0 && len(t.Data[0]) == 1 {
for i := range t.Data {
if len(t.Data[i]) == 0 {
continue
}
values = append(values, t.Data[i][0])
}
}
return values
}
func (t *DataTable) MatchFields(from []*Field) []*Field {
return from
}