Initial commit

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
谢宇宁
2026-09-29 11:47:47 +07:00
co-authored by Claude Opus 5.5
commit 0fbdba5ccf
622 changed files with 72105 additions and 0 deletions
+52
View File
@@ -0,0 +1,52 @@
package web
import (
"strconv"
"strings"
"github.com/gin-gonic/gin"
)
const maxAccountPage = 10000
type accountPage struct {
Current int
Total int
Count int64
PrevURL string
NextURL string
}
func accountPageNum(c *gin.Context) (int, bool) {
if c.Request.URL.Query().Has("page") {
return 0, false
}
raw := strings.TrimSpace(c.Param("page"))
if raw == "" {
return 1, true
}
page, err := strconv.Atoi(raw)
if err != nil || page < 1 || page > maxAccountPage {
return 0, false
}
return page, true
}
func makeAccountPage(path string, page, size int, count int64) accountPage {
total := int((count + int64(size) - 1) / int64(size))
p := accountPage{Current: page, Total: total, Count: count}
link := func(n int) string {
path = strings.TrimRight(path, "/")
if n <= 1 {
return path
}
return path + "/page/" + strconv.Itoa(n)
}
if page > 1 {
p.PrevURL = link(page - 1)
}
if page < total {
p.NextURL = link(page + 1)
}
return p
}