replace zxq.co/ripple/hanayo
This commit is contained in:
22
vendor/zxq.co/ripple/rippleapi/common/paginate.go
vendored
Normal file
22
vendor/zxq.co/ripple/rippleapi/common/paginate.go
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
package common
|
||||
|
||||
import "fmt"
|
||||
|
||||
// Paginate creates an additional SQL LIMIT clause for paginating.
|
||||
func Paginate(page, limit string, maxLimit int) string {
|
||||
var (
|
||||
p = Int(page)
|
||||
l = Int(limit)
|
||||
)
|
||||
if p < 1 {
|
||||
p = 1
|
||||
}
|
||||
if l < 1 {
|
||||
l = 50
|
||||
}
|
||||
if l > maxLimit {
|
||||
l = maxLimit
|
||||
}
|
||||
start := uint(p-1) * uint(l)
|
||||
return fmt.Sprintf(" LIMIT %d,%d ", start, l)
|
||||
}
|
Reference in New Issue
Block a user