-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathresult.go
37 lines (32 loc) · 890 Bytes
/
result.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package main
import (
"github.com/gin-gonic/gin"
"net/http"
)
// 请求返回成功
func SuccessJSON(c *gin.Context, msg string, data interface{}) {
//var d = &struct {
// code int
// message string
// data interface{}
//}{code:code,message:msg,data:data}
c.JSON(http.StatusOK, gin.H{"code": http.StatusOK, "message": msg, "data": data})
}
// 请求返回错误
func ErrorJSON(c *gin.Context, code int, msg string) {
//var d = &struct {
// code int
// message string
// data interface{}
//}{code:code,message:msg,data:""}
c.JSON(http.StatusOK, gin.H{"code": code, "message": msg, "data": ""})
}
// 默认系统错误
func SystemErrorJSON(c *gin.Context, code int, msg string) {
//var d = &struct {
// code int
// message string
// data interface{}
//}{code:code,message:msg,data:""}
c.JSON(code, gin.H{"code": code, "message": msg, "data": ""})
}