You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

34 lines
538 B
Go

package controller
import (
"github.com/gin-gonic/gin"
"net/http"
)
/**
* 成功时返回
*/
func Success(c *gin.Context, data interface{}) {
c.JSON(http.StatusOK, gin.H{
"code": 0,
"message": "ok",
"request_uri": c.Request.URL.Path,
"data": data,
})
c.Abort()
}
/**
* 失败时返回
*/
func Error(c *gin.Context, msg string) {
c.JSON(http.StatusOK, gin.H{
"code": 400,
"message": msg,
"request_uri": c.Request.URL.Path,
"data": make(map[string]string),
})
c.Abort()
}