|
|
|
@ -8,7 +8,8 @@ import ( |
|
|
|
|
|
|
|
|
|
const ( |
|
|
|
|
DefaultPage = 1 |
|
|
|
|
MinPageSize = 10 |
|
|
|
|
MinPageSize = 1 |
|
|
|
|
DefaultPageSize = 10 |
|
|
|
|
MaxPageSize = 1000 |
|
|
|
|
) |
|
|
|
|
|
|
|
|
@ -29,6 +30,10 @@ func PageToSlice[T Integer](page, pageSize, total T) (begin, end T) { |
|
|
|
|
page = DefaultPage |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if pageSize <= 0 { |
|
|
|
|
pageSize = DefaultPageSize |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if pageSize <= MinPageSize { |
|
|
|
|
pageSize = MinPageSize |
|
|
|
|
} |
|
|
|
@ -58,6 +63,10 @@ func PageToOffset[T Integer](page, pageSize T) (offset, limit T) { |
|
|
|
|
page = DefaultPage |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if pageSize <= 0 { |
|
|
|
|
pageSize = DefaultPageSize |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if pageSize <= MinPageSize { |
|
|
|
|
pageSize = MinPageSize |
|
|
|
|
} |
|
|
|
|