first commit

This commit is contained in:
2026-08-14 23:41:57 +08:00
commit 086803a8dd
471 changed files with 91938 additions and 0 deletions
+31
View File
@@ -0,0 +1,31 @@
package server
import (
"net/http"
"strconv"
"github.com/gin-gonic/gin"
)
// fail 统一错误响应:{ "error": "..." }
func fail(c *gin.Context, status int, message string) {
c.JSON(status, gin.H{"error": message})
}
// ok 统一成功响应。
func ok(c *gin.Context, data gin.H) {
c.JSON(http.StatusOK, data)
}
// parsePagination 解析 limit / offset 查询参数(非法值归零)。
func parsePagination(c *gin.Context) (limit, offset int) {
limit, _ = strconv.Atoi(c.Query("limit"))
offset, _ = strconv.Atoi(c.Query("offset"))
if limit < 0 {
limit = 0
}
if offset < 0 {
offset = 0
}
return
}