package result import ( "net/http" "github.com/zeromicro/go-zero/rest/httpx" ) type Response struct { Code int `json:"code"` Msg string `json:"msg"` Data interface{} `json:"data"` } func Success(data interface{}) *Response { return &Response{Code: 0, Msg: "success", Data: data} } func Error(code int, msg string) *Response { return &Response{Code: code, Msg: msg, Data: nil} } func OkJson(w http.ResponseWriter, data interface{}) { httpx.OkJson(w, Success(data)) }