init
This commit is contained in:
commit
aee8bcc886
18 files changed
+960
No files matched your search
@@ -0,0 +1,29 @@
|
||||
package response
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
type Response struct {
|
||||
Code int `json:"code"`
|
||||
Message string `json:"message"`
|
||||
Data any `json:"data"`
|
||||
}
|
||||
|
||||
func Success(ctx *gin.Context, data any) {
|
||||
ctx.JSON(http.StatusOK, Response{
|
||||
Code: 0,
|
||||
Message: "success",
|
||||
Data: data,
|
||||
})
|
||||
}
|
||||
|
||||
func Error(ctx *gin.Context, status int, message string) {
|
||||
ctx.AbortWithStatusJSON(status, Response{
|
||||
Code: status,
|
||||
Message: message,
|
||||
Data: nil,
|
||||
})
|
||||
}
|
||||
Reference in new issue
Block a user