27 lines
620 B
Go
27 lines
620 B
Go
package utils
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
const (
|
|
SUCCESS = "Success"
|
|
)
|
|
|
|
func Success(c *gin.Context, status int, code int, msg interface{}, data interface{}) {
|
|
c.JSON(http.StatusOK, GinResponse{Code: code, Msg: msg, Data: data})
|
|
}
|
|
|
|
func Error(c *gin.Context, status int, code int, msg interface{}, data interface{}) {
|
|
c.JSON(status, GinResponse{Code: code, Msg: msg, Data: data})
|
|
}
|
|
|
|
func Succ(c *gin.Context, data interface{}) {
|
|
Success(c, http.StatusOK, http.StatusOK, SUCCESS, data)
|
|
}
|
|
func Err(c *gin.Context, status int, code int, msg interface{}) {
|
|
Error(c, status, code, msg, nil)
|
|
}
|