This commit is contained in:
Yvan
2026-08-17 07:44:52 +08:00
parent d09e6b42bd
commit 9715b2ef1a
28 changed files with 1586 additions and 326 deletions
+38
View File
@@ -0,0 +1,38 @@
package handler
import (
"strconv"
"github.com/gin-gonic/gin"
)
func page(c *gin.Context) (int, int, error) {
var value, size int
if raw, exists := c.GetQuery("page"); exists && raw != "" {
parsed, err := strconv.Atoi(raw)
if err != nil {
return 0, 0, err
}
value = parsed
}
if raw, exists := c.GetQuery("pageSize"); exists && raw != "" {
parsed, err := strconv.Atoi(raw)
if err != nil {
return 0, 0, err
}
size = parsed
}
return value, size, nil
}
func IDsFromQuery(c *gin.Context) []uint {
values := c.QueryArray("IDs[]")
ids := make([]uint, 0, len(values))
for _, value := range values {
id, _ := strconv.ParseUint(value, 10, 64)
if id > 0 {
ids = append(ids, uint(id))
}
}
return ids
}