refactor: simplify route handlers by removing redundant ID parsing logic

This commit is contained in:
mlogclub
2026-05-23 22:28:21 +08:00
parent 1852f9df8b
commit f9ddf39c83
25 changed files with 155 additions and 195 deletions
+18
View File
@@ -0,0 +1,18 @@
package httpx
import (
"net/http"
"strconv"
"github.com/gin-gonic/gin"
"github.com/mlogclub/simple/web"
)
func GetPathInt64(ctx *gin.Context, name string) (int64, bool) {
value, err := strconv.ParseInt(ctx.Param(name), 10, 64)
if err != nil {
WriteHttpStatusJSON(ctx, http.StatusBadRequest, web.JsonErrorMsg("路径参数错误"))
return 0, false
}
return value, true
}