37 lines
878 B
Go
37 lines
878 B
Go
package playletser
|
|
|
|
import (
|
|
"strconv"
|
|
"strings"
|
|
)
|
|
|
|
func todayUpdatePageURL(pageNum int) string {
|
|
if pageNum <= 1 {
|
|
return "/recently-added"
|
|
}
|
|
return "/recently-added/page/" + strconv.Itoa(pageNum)
|
|
}
|
|
|
|
func TodayUpdateCanonicalPath(q TodayUpdateQuery) string {
|
|
q.Normalize()
|
|
return todayUpdatePageURL(q.PageNum)
|
|
}
|
|
|
|
// BuildTodayUpdatePagination 今日更新分页。
|
|
func BuildTodayUpdatePagination(q TodayUpdateQuery, totalCount int64) PaginationVM {
|
|
q.Normalize()
|
|
return BuildPagination(func(p int) string {
|
|
return todayUpdatePageURL(p)
|
|
}, q.PageNum, q.PageSize, totalCount)
|
|
}
|
|
|
|
// ParseTodayUpdateQuery 从 query 解析分页。
|
|
func ParseTodayUpdateQuery(pageStr string) TodayUpdateQuery {
|
|
q := TodayUpdateQuery{PageSize: defaultTodayUpdateSize}
|
|
if n, err := strconv.Atoi(strings.TrimSpace(pageStr)); err == nil {
|
|
q.PageNum = n
|
|
}
|
|
q.Normalize()
|
|
return q
|
|
}
|