From 179157f49ee484ea8129588da692edff0a5b044d Mon Sep 17 00:00:00 2001 From: yanweidong Date: Tue, 14 Oct 2025 14:48:44 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8DReply=E7=BB=93=E6=9E=84?= =?UTF-8?q?=E4=BD=93=E4=B8=AD=E7=9A=84=E5=AD=97=E6=AE=B5=E5=90=8D=E7=A7=B0?= =?UTF-8?q?=EF=BC=8C=E6=9B=B4=E6=96=B0=E6=88=90=E5=8A=9F=E5=92=8C=E9=94=99?= =?UTF-8?q?=E8=AF=AF=E5=93=8D=E5=BA=94=E6=96=B9=E6=B3=95=E4=BB=A5=E4=BD=BF?= =?UTF-8?q?=E7=94=A8=E6=96=B0=E7=9A=84=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- infra/response.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/infra/response.go b/infra/response.go index ec19539..fc6993e 100644 --- a/infra/response.go +++ b/infra/response.go @@ -3,6 +3,8 @@ package infra import ( + "time" + "github.com/gin-gonic/gin" "google.golang.org/grpc/status" ) @@ -13,7 +15,8 @@ var Response Reply type Reply struct { Code int32 `json:"code"` // 响应码 Message string `json:"message"` // 响应消息 - Result any `json:"result"` // 响应数据 + Details any `json:"details"` // 响应数据 + Timeseq int64 `json:"timeseq"` // 时间戳序列 } // Success 返回成功响应 @@ -21,10 +24,11 @@ type Reply struct { // data: 响应数据 func (reply *Reply) Success(ctx *gin.Context, data any) { reply.Code = 0 - reply.Result = data + reply.Details = data reply.Message = "" + reply.Timeseq = time.Now().UnixMilli() if data == nil { - reply.Result = "" + reply.Details = "" } ctx.JSON(200, reply) } @@ -34,7 +38,7 @@ func (reply *Reply) Success(ctx *gin.Context, data any) { // err: 错误对象 func (reply *Reply) Error(ctx *gin.Context, err error) { reply.Code = 500 - reply.Result = "" + reply.Details = "" // 默认状态码为500 e, ok := status.FromError(err) if ok {