This commit is contained in:
yanweidong 2025-02-20 17:41:21 +08:00
commit d4b7e7e9e6
1 changed files with 2 additions and 1 deletions

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