增加getuint64/32的方法

This commit is contained in:
2025-12-07 01:09:52 +08:00
parent 5cfa0d7ce5
commit 545c6ef6a4
3 changed files with 54 additions and 0 deletions

View File

@@ -223,6 +223,34 @@ func GetQueryFloat64(r *http.Request, key string, defaultValue float64) float64
return floatValue
}
func GetQueryUint64(r *http.Request, key string, defaultValue uint64) uint64 {
value := r.URL.Query().Get(key)
if value == "" {
return defaultValue
}
uintValue, err := strconv.ParseUint(value, 10, 64)
if err != nil {
return defaultValue
}
return uintValue
}
func GetQueryUint32(r *http.Request, key string, defaultValue uint32) uint32 {
value := r.URL.Query().Get(key)
if value == "" {
return defaultValue
}
uintValue, err := strconv.ParseUint(value, 10, 32)
if err != nil {
return defaultValue
}
return uint32(uintValue)
}
// GetFormValue 获取表单值(公共方法)
// r: HTTP请求
// key: 参数名