From 73e5a166ebadfb9db09f01be074dbc6a7f1c4b3a Mon Sep 17 00:00:00 2001 From: Acexy Date: Mon, 24 Jun 2024 15:14:11 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E9=83=A8=E5=88=86=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E5=91=BD=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ginmodule/request.go | 4 ++-- ginmodule/response.go | 6 +++--- ginmodule/{status.go => rest.go} | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) rename ginmodule/{status.go => rest.go} (96%) diff --git a/ginmodule/request.go b/ginmodule/request.go index 67465af..1976593 100644 --- a/ginmodule/request.go +++ b/ginmodule/request.go @@ -183,9 +183,9 @@ func (r *Request) BindBodyJson(object any) error { return r.ctx.ShouldBindJSON(object) } -// MustBodyJson 将请求body数据绑定到json结构体中 +// MustBindBodyJson 将请求body数据绑定到json结构体中 // 任何错误将触发Panic流程中断 -func (r *Request) MustBodyJson(object any) { +func (r *Request) MustBindBodyJson(object any) { err := r.BindBodyJson(object) if err != nil { panic(&internalPanic{ diff --git a/ginmodule/response.go b/ginmodule/response.go index 6007d99..315084d 100644 --- a/ginmodule/response.go +++ b/ginmodule/response.go @@ -126,7 +126,7 @@ func RespRestStatusError(statusCode StatusCode, statusMessage ...StatusMessage) } // RespRestBizError 响应标准格式的Rest业务错误 -func RespRestBizError(bizErrorCode BizErrorCode, bizErrorMessage BizErrorMessage) Response { +func RespRestBizError(bizErrorCode *BizErrorCode, bizErrorMessage *BizErrorMessage) Response { dataRest := &RestRespStruct{ Status: &RestRespStatusStruct{ StatusCode: StatusCodeSuccess, @@ -179,8 +179,8 @@ func (c *commonResp) ToResponse() Response { return c } -// RespStatusCode 设置响应状态码 -func RespStatusCode(statusCode int) Response { +// RespHttpStatusCode 设置响应状态码 +func RespHttpStatusCode(statusCode int) Response { return &commonResp{ginFn: func(context *gin.Context) { context.Status(statusCode) }} diff --git a/ginmodule/status.go b/ginmodule/rest.go similarity index 96% rename from ginmodule/status.go rename to ginmodule/rest.go index 0b74d65..51ebc6c 100644 --- a/ginmodule/status.go +++ b/ginmodule/rest.go @@ -67,8 +67,8 @@ type RestRespStatusStruct struct { StatusMessage StatusMessage `json:"statusMessage"` // 业务错误码 仅当StatusCode为200时进入业务错误判断 - BizErrorCode BizErrorCode `json:"bizErrorCode"` - BizErrorMessage BizErrorMessage `json:"bizErrorMessage"` + BizErrorCode *BizErrorCode `json:"bizErrorCode"` + BizErrorMessage *BizErrorMessage `json:"bizErrorMessage"` // 系统响应时间戳 Timestamp int64 `json:"timestamp"`