Documentation ¶
Index ¶
Constants ¶
View Source
const ( // PAGENUM identifies the page number of the data. // The default value is 0. PAGENUM = "pageNum" // PAGESIZE identifies the page size of the data. // If this value equals 0, return all values. PAGESIZE = "pageSize" // SORTKEY identifies the sort key of the data. // Each mgr needs to define acceptable values based on its own implementation. SORTKEY = "sortKey" // SORTDIRECT identifies the sort direct of the data. // The value can only be ASC or DESC. SORTDIRECT = "sortDirect" // ASCDIRECT means to sort the records in ascending order. ASCDIRECT = "ASC" // DESCDIRECT means to sort the records in descending order. DESCDIRECT = "DESC" )
Variables ¶
This section is empty.
Functions ¶
func GetPageValues ¶
func GetPageValues(metaSlice []interface{}, pageNum, pageSize int, less func(i, j int) bool) []interface{}
GetPageValues gets some pages of metaSlice after ordering it. The less is a function that reports whether the element with index i should sort before the element with index j.
Eg:
people := []struct { Name string Age int }{
{"Gopher", 7}, {"Alice", 55}, {"Vera", 24}, {"Bob", 75}, }
If you want to sort it by age, and the less function should be defined as follows:
less := func(i, j int) bool { return people[i].Age < people[j].Age }
func ValidateFilter ¶
func ValidateFilter(pageFilter *PageFilter, sortKeyMap map[string]bool) error
ValidateFilter validates the param of filter. The caller should customize the sortKeyMap which specifies the sort keys it supports.
Types ¶
type PageFilter ¶
PageFilter is a struct.
func ParseFilter ¶
ParseFilter gets filter params from request and returns a map[string][]string.
Click to show internal directories.
Click to hide internal directories.