Files
bj_power/bj_power_workstation/internal/handler/common.go
T

25 lines
420 B
Go
Raw Normal View History

2026-08-27 19:50:57 +08:00
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
}