package handler import ( "encoding/json" "net/http" "strconv" ) // parseJSON 解析请求体 JSON,失败返回错误(风格仿 bj_power_wms/internal/handler/common.go) func parseJSON(r *http.Request, v any) error { dec := json.NewDecoder(r.Body) return dec.Decode(v) } func atoi(s string, def int) int { if s == "" { return def } n, err := strconv.Atoi(s) if err != nil { return def } return n }