首次提交

This commit is contained in:
yangy
2026-05-21 15:20:12 +08:00
commit 3224041990
32 changed files with 1504 additions and 0 deletions
+36
View File
@@ -0,0 +1,36 @@
package response
import (
"net/http"
"github.com/gin-gonic/gin"
)
type Body struct {
Code int `json:"code"`
Message string `json:"message"`
Data any `json:"data,omitempty"`
}
func OK(c *gin.Context, data any) {
c.JSON(http.StatusOK, Body{
Code: 0,
Message: "ok",
Data: data,
})
}
func Fail(c *gin.Context, httpStatus int, code int, message string) {
c.JSON(httpStatus, Body{
Code: code,
Message: message,
})
}
func BadRequest(c *gin.Context, message string) {
Fail(c, http.StatusBadRequest, 40000, message)
}
func InternalError(c *gin.Context, message string) {
Fail(c, http.StatusInternalServerError, 50000, message)
}