初始化2

This commit is contained in:
SunYF
2026-08-28 15:06:01 +08:00
parent b34325a16f
commit a9c3fbeb41
537 changed files with 176215 additions and 17 deletions
@@ -0,0 +1,22 @@
package handler
import (
"net/http"
"github.com/zeromicro/go-zero/rest/httpx"
)
// Response 统一响应结构:{ code, message, data }
type Response struct {
Code int `json:"code"`
Message string `json:"message"`
Data any `json:"data,omitempty"`
}
func ok(w http.ResponseWriter, data any) {
httpx.WriteJson(w, http.StatusOK, Response{Code: 0, Message: "ok", Data: data})
}
func fail(w http.ResponseWriter, httpStatus int, message string) {
httpx.WriteJson(w, httpStatus, Response{Code: -1, Message: message})
}