From 9031b9543bdf8f73fb54c287ffad94574fe90575 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E8=8C=B6=E6=B8=85=E6=AC=A2?= Date: Sun, 26 Jun 2022 13:03:41 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=93=8D=E5=BA=94=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- go.mod | 2 +- go.sum | 4 ++++ response/response.go | 9 ++++----- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/go.mod b/go.mod index ee8a55a..f3fe361 100644 --- a/go.mod +++ b/go.mod @@ -2,7 +2,7 @@ module git.zhangdeman.cn/zhangdeman/gin go 1.17 -require git.zhangdeman.cn/zhangdeman/exception v0.0.0-20220625143611-42a85f7b80c3 +require git.zhangdeman.cn/zhangdeman/exception v0.0.0-20220626050013-dce8cafff2c6 require ( git.zhangdeman.cn/zhangdeman/util v0.0.0-20220625151616-cfe1f4c04db4 // indirect diff --git a/go.sum b/go.sum index c7725f1..16e40f7 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,9 @@ git.zhangdeman.cn/zhangdeman/exception v0.0.0-20220625143611-42a85f7b80c3 h1:bQh+GCEfdusiirGm/XV7gqt7dkejqnvFxplatBUrSSI= git.zhangdeman.cn/zhangdeman/exception v0.0.0-20220625143611-42a85f7b80c3/go.mod h1:mIMM/t9BkrKHAcDCmarLCHQhHfWf0/ZjtcqJPboqmSA= +git.zhangdeman.cn/zhangdeman/exception v0.0.0-20220626045509-282f54bb736a h1:n9kssd90WV55PsAWJNjSdAYTtZ6ACrZgiv9TEIcsNdA= +git.zhangdeman.cn/zhangdeman/exception v0.0.0-20220626045509-282f54bb736a/go.mod h1:mIMM/t9BkrKHAcDCmarLCHQhHfWf0/ZjtcqJPboqmSA= +git.zhangdeman.cn/zhangdeman/exception v0.0.0-20220626050013-dce8cafff2c6 h1:+hAz/NpZvdsMZefwiV30bJ8Tzon+Bzs/HWiZi/9SOtc= +git.zhangdeman.cn/zhangdeman/exception v0.0.0-20220626050013-dce8cafff2c6/go.mod h1:mIMM/t9BkrKHAcDCmarLCHQhHfWf0/ZjtcqJPboqmSA= git.zhangdeman.cn/zhangdeman/util v0.0.0-20220609072516-022a755fdf2f h1:yAxxukVUdSM5wn264el+QiAEB0OBN/5H7Xw9Z6rLzUY= git.zhangdeman.cn/zhangdeman/util v0.0.0-20220609072516-022a755fdf2f/go.mod h1:YI/XeTmrr9+8dxa4ThPkmNcEE8WHG5pZkKujpSWwIxM= git.zhangdeman.cn/zhangdeman/util v0.0.0-20220625151616-cfe1f4c04db4 h1:uHYTRztH/XEVtr3FLykCf/3LhFQ7zQHnzVAeDyC1huQ= diff --git a/response/response.go b/response/response.go index dd79a02..55ad911 100644 --- a/response/response.go +++ b/response/response.go @@ -31,17 +31,16 @@ func Success(ctx *gin.Context, data map[string]interface{}) { // Author : go_developer@163.com<白茶清欢> // // Date : 22:40 2022/6/25 -func Send(ctx *gin.Context, code interface{}, httpCode int, data map[string]interface{}) { - e := exception.New(code, httpCode, data) +func Send(ctx *gin.Context, code interface{}, httpCode int, data interface{}) { responseData := map[string]interface{}{ - define.ResponseCodeField: e.GetCode(), - define.ResponseMessageField: e.GetMessage(), + define.ResponseCodeField: code, + define.ResponseMessageField: exception.GetMessage(code), define.ResponseTraceIDField: ctx.GetString(define.TraceIDField), define.ResponseRequestIDField: ctx.GetString(define.RequestIDField), define.ResponseDataField: data, define.HandleRequestCostField: (time.Now().UnixNano() - ctx.GetInt64(define.StartRequestTimeField)) / 1e9, } - responseException := exception.New(e.GetCode(), e.GetHttpCode(), responseData) + responseException := exception.New(code, httpCode, responseData) ctx.JSON(responseException.GetHttpCode(), responseException.GetData()) }