ch some
Some checks failed
CI/CD / Vet, test, build (push) Has been cancelled
CI/CD / Docker image (push) Has been cancelled
CI/CD / Deploy binary to server (push) Has been cancelled

This commit is contained in:
2026-09-04 19:33:26 +05:00
parent 28509eb4ca
commit d1a6fcaadc
102 changed files with 2089 additions and 1957 deletions

View File

@@ -5,22 +5,10 @@ import (
"strings"
"github.com/gin-gonic/gin"
)
const (
defaultPage = 1
defaultLimit = 10
maxLimit = 100
"online-back/internal/shared"
)
func parseID(raw string) (int64, bool) {
id, err := strconv.ParseInt(raw, 10, 64)
if err != nil || id <= 0 {
return 0, false
}
return id, true
}
func queryValue(c *gin.Context, keys ...string) string {
for _, key := range keys {
if raw := strings.TrimSpace(c.Query(key)); raw != "" && raw != "undefined" && raw != "null" {
@@ -31,8 +19,8 @@ func queryValue(c *gin.Context, keys ...string) string {
}
func parsePageLimit(c *gin.Context) (page, limit int, ok bool) {
page = defaultPage
limit = defaultLimit
page = shared.DefaultPage
limit = shared.DefaultLimit
if raw := queryValue(c, "page"); raw != "" {
p, err := strconv.Atoi(raw)
@@ -47,8 +35,8 @@ func parsePageLimit(c *gin.Context) (page, limit int, ok bool) {
if err != nil || l < 1 {
return 0, 0, false
}
if l > maxLimit {
l = maxLimit
if l > shared.MaxLimit {
l = shared.MaxLimit
}
limit = l
}