24 lines
369 B
Go
24 lines
369 B
Go
package util
|
|
|
|
import (
|
|
"github.com/gin-gonic/gin"
|
|
"net/http"
|
|
)
|
|
|
|
func ReturnJson(c *gin.Context, code int, msg string, data interface{}) {
|
|
c.JSON(http.StatusOK, gin.H{
|
|
"code": code,
|
|
"msg": msg,
|
|
"data": data,
|
|
})
|
|
}
|
|
|
|
func ReturnInvalid(c *gin.Context) {
|
|
response := gin.H{
|
|
"code": 4,
|
|
"msg": "无效请求参数",
|
|
"data": nil,
|
|
}
|
|
c.JSON(200, response)
|
|
}
|