Initial commit

This commit is contained in:
zs
2026-02-28 20:05:15 +08:00
commit c66f5f9be4
185 changed files with 18356 additions and 0 deletions

View File

@@ -0,0 +1,32 @@
package handler
import (
"encoding/json"
"net/http"
)
type Response struct {
Code int `json:"code"`
Message string `json:"message"`
Data interface{} `json:"data"`
}
func SendSuccess(w http.ResponseWriter, data interface{}) {
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(http.StatusOK)
json.NewEncoder(w).Encode(Response{
Code: 200,
Message: "success",
Data: data,
})
}
func SendError(w http.ResponseWriter, httpStatus int, bizCode int, message string) {
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(httpStatus)
json.NewEncoder(w).Encode(Response{
Code: bizCode,
Message: message,
Data: nil,
})
}