Initial commit
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
package playletser
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func todayUpdatePageURL(pageNum int) string {
|
||||
if pageNum <= 1 {
|
||||
return "/today-update/"
|
||||
}
|
||||
return "/today-update/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
|
||||
}
|
||||
Reference in New Issue
Block a user