Compare commits

...

1 Commits

Author SHA1 Message Date
zhaoxiaorong
629ec74be6 response fix 2025-02-20 15:58:54 +08:00

View File

@@ -16,6 +16,7 @@ type Reply struct {
func (reply *Reply) Success(ctx *gin.Context, data any) {
reply.Code = 200
reply.Data = data
reply.Msg = ""
if data == nil {
reply.Data = ""
}
@@ -23,12 +24,12 @@ func (reply *Reply) Success(ctx *gin.Context, data any) {
}
func (reply *Reply) Error(ctx *gin.Context, err error) {
reply.Code = 500
reply.Data = ""
// Status code defaults to 500
e, ok := status.FromError(err)
if ok {
reply.Code = int(e.Code())
}
reply.Msg = e.Message()
// Send error