feat: 前端搭建-未完成

This commit is contained in:
tbphp
2025-06-29 21:59:32 +08:00
parent ab95af0bbe
commit 731315144e
62 changed files with 4831 additions and 604 deletions

View File

@@ -0,0 +1,48 @@
// Package response provides standardized JSON response helpers.
package response
import (
"net/http"
"github.com/gin-gonic/gin"
)
// Response defines the standard JSON response structure.
type Response struct {
Code int `json:"code"`
Message string `json:"message"`
Data interface{} `json:"data,omitempty"`
}
// Success sends a standardized success response.
func Success(c *gin.Context, data interface{}) {
c.JSON(http.StatusOK, Response{
Code: 0,
Message: "Success",
Data: data,
})
}
// Error sends a standardized error response.
func Error(c *gin.Context, code int, message string) {
c.JSON(code, Response{
Code: code,
Message: message,
Data: nil,
})
}
// BadRequest sends a 400 Bad Request error response.
func BadRequest(c *gin.Context, message string) {
Error(c, http.StatusBadRequest, message)
}
// NotFound sends a 404 Not Found error response.
func NotFound(c *gin.Context, message string) {
Error(c, http.StatusNotFound, message)
}
// InternalError sends a 500 Internal Server Error response.
func InternalError(c *gin.Context, message string) {
Error(c, http.StatusInternalServerError, message)
}