package response import "github.com/gogf/gf/v2/net/ghttp" // Body 是两套 API 共用的唯一 JSON 响应信封。 type Body struct { Code int `json:"code"` Message string `json:"message"` Data any `json:"data,omitempty"` } func JSON(r *ghttp.Request, code int, message string, data any) { r.Response.WriteJsonExit(Body{Code: code, Message: message, Data: data}) } func OK(r *ghttp.Request, data any) { JSON(r, 0, "ok", data) }