You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
444 B
24 lines
444 B
package common
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
func Response(ctx *gin.Context, httpStatus int, code int, data gin.H, msg string) {
|
|
ctx.JSON(httpStatus, gin.H{
|
|
"code": code,
|
|
"data": data,
|
|
"msg": msg,
|
|
})
|
|
}
|
|
|
|
func Success(ctx *gin.Context, data gin.H, msg string) {
|
|
Response(ctx, http.StatusOK, 200, data, msg)
|
|
}
|
|
|
|
func Fail(ctx *gin.Context, data gin.H, msg string) {
|
|
Response(ctx, http.StatusOK, 400, data, msg)
|
|
}
|