2 Commits

Author SHA1 Message Date
956cf69a82 feat: 添加 resp RC 2025-08-06 15:57:49 +08:00
61a115852e fix: 修复 resp RE 返回时 error 问题 2025-07-23 10:32:47 +08:00

View File

@ -30,6 +30,18 @@ func R200(c *gin.Context, data any, msgs ...string) {
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) {
var re *Error
@ -68,11 +80,7 @@ H4:
r.Code = code
}
H3:
if es, ok := args[2].(error); ok {
r.Err = es.Error()
} else {
r.Err = args[2]
}
r.Err = args[2]
H2:
r.Data = args[1]
H1:
@ -86,6 +94,10 @@ END:
r.Msg = Msg(r.Status)
}
if ce, ok := r.Err.(error); ok {
r.Err = ce.Error()
}
c.AbortWithStatusJSON(r.Status, r)
}