初始化

This commit is contained in:
SunYF
2026-08-28 14:07:22 +08:00
parent a185247ab1
commit b34325a16f
971 changed files with 291 additions and 220360 deletions
-53
View File
@@ -1,53 +0,0 @@
package handler
import (
"context"
"encoding/json"
"net/http"
"strconv"
"time"
)
func timeNow() time.Time {
return time.Now()
}
func ctx0() context.Context {
return context.Background()
}
// parseJSON 解析请求体 JSON,失败返回错误
func parseJSON(r *http.Request, v any) error {
dec := json.NewDecoder(r.Body)
dec.DisallowUnknownFields()
return dec.Decode(v)
}
func strPtr(s string) *string {
if s == "" {
return nil
}
return &s
}
func atoi(s string, def int) int {
if s == "" {
return def
}
n, err := strconv.Atoi(s)
if err != nil {
return def
}
return n
}
func atoi64(s string, def int64) int64 {
if s == "" {
return def
}
n, err := strconv.ParseInt(s, 10, 64)
if err != nil {
return def
}
return n
}