Compare commits
2 Commits
Author | SHA1 | Date | |
---|---|---|---|
956cf69a82 | |||
61a115852e |
22
resp/resp.go
22
resp/resp.go
@ -30,6 +30,18 @@ func R200(c *gin.Context, data any, msgs ...string) {
|
|||||||
c.AbortWithStatusJSON(200, r)
|
c.AbortWithStatusJSON(200, r)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func RC(c *gin.Context, status int, args ...any) {
|
||||||
|
code := 1
|
||||||
|
if status != 200 {
|
||||||
|
code = -1
|
||||||
|
}
|
||||||
|
|
||||||
|
_r(c, &res{
|
||||||
|
Status: status,
|
||||||
|
Code: code,
|
||||||
|
}, args...)
|
||||||
|
}
|
||||||
|
|
||||||
func RE(c *gin.Context, err error) {
|
func RE(c *gin.Context, err error) {
|
||||||
var re *Error
|
var re *Error
|
||||||
|
|
||||||
@ -68,11 +80,7 @@ H4:
|
|||||||
r.Code = code
|
r.Code = code
|
||||||
}
|
}
|
||||||
H3:
|
H3:
|
||||||
if es, ok := args[2].(error); ok {
|
r.Err = args[2]
|
||||||
r.Err = es.Error()
|
|
||||||
} else {
|
|
||||||
r.Err = args[2]
|
|
||||||
}
|
|
||||||
H2:
|
H2:
|
||||||
r.Data = args[1]
|
r.Data = args[1]
|
||||||
H1:
|
H1:
|
||||||
@ -86,6 +94,10 @@ END:
|
|||||||
r.Msg = Msg(r.Status)
|
r.Msg = Msg(r.Status)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ce, ok := r.Err.(error); ok {
|
||||||
|
r.Err = ce.Error()
|
||||||
|
}
|
||||||
|
|
||||||
c.AbortWithStatusJSON(r.Status, r)
|
c.AbortWithStatusJSON(r.Status, r)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user