|
@ -5,8 +5,10 @@ import ( |
|
|
) |
|
|
) |
|
|
|
|
|
|
|
|
const ( |
|
|
const ( |
|
|
PageSize = "pageSize" |
|
|
|
|
|
PageNumber = "pageNumber" |
|
|
|
|
|
|
|
|
PageSize = "pageSize" |
|
|
|
|
|
_PageSize = "_pageSize" |
|
|
|
|
|
PageNumber = "pageNumber" |
|
|
|
|
|
_PageNumber = "_pageNumber" |
|
|
) |
|
|
) |
|
|
|
|
|
|
|
|
type Paging struct { |
|
|
type Paging struct { |
|
@ -33,20 +35,22 @@ func (self *Paging) Fill(urlParameters map[string]string) bool { |
|
|
return false |
|
|
return false |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func getValue(urlParameters map[string]string, name string, defaultValue int64) (int64, bool) { |
|
|
|
|
|
if urlParameter, ok := urlParameters[name]; ok { |
|
|
|
|
|
value, err := strconv.ParseInt(urlParameter, 10, 64) |
|
|
|
|
|
if err == nil { |
|
|
|
|
|
return value, true |
|
|
|
|
|
|
|
|
func getValue(urlParameters map[string]string, names []string, defaultValue int64) (int64, bool) { |
|
|
|
|
|
for _, name := range names { |
|
|
|
|
|
if urlParameter, ok := urlParameters[name]; ok { |
|
|
|
|
|
value, err := strconv.ParseInt(urlParameter, 10, 64) |
|
|
|
|
|
if err == nil { |
|
|
|
|
|
return value, true |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
return defaultValue, false |
|
|
return defaultValue, false |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func getPageIndex(urlParameters map[string]string) (int64, bool) { |
|
|
func getPageIndex(urlParameters map[string]string) (int64, bool) { |
|
|
return getValue(urlParameters, PageNumber, 1) |
|
|
|
|
|
|
|
|
return getValue(urlParameters, []string{_PageNumber, PageNumber}, 1) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func getPageSize(urlParameters map[string]string) (int64, bool) { |
|
|
func getPageSize(urlParameters map[string]string) (int64, bool) { |
|
|
return getValue(urlParameters, PageSize, 10) |
|
|
|
|
|
|
|
|
return getValue(urlParameters, []string{_PageSize, PageSize}, 1) |
|
|
} |
|
|
} |