From 36dee32db8732b5dc10fdc6a5e6aa11448e92749 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E8=8C=B6=E6=B8=85=E6=AC=A2?= Date: Fri, 31 Oct 2025 23:31:14 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=95=B0=E6=8D=AE=E8=A7=A3=E6=9E=90?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E8=AE=BE=E7=BD=AE=E9=BB=98=E8=AE=A4=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- router/handler.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/router/handler.go b/router/handler.go index 084a817..39e285e 100644 --- a/router/handler.go +++ b/router/handler.go @@ -18,6 +18,7 @@ import ( "git.zhangdeman.cn/zhangdeman/gin/request" "git.zhangdeman.cn/zhangdeman/gin/response" "github.com/gin-gonic/gin" + "github.com/mcuadros/go-defaults" ) func (s *server) getFormInitValue(ctx *gin.Context, uriCfg UriConfig) (any, error) { @@ -63,6 +64,7 @@ func (s *server) RequestHandler(uriCfg UriConfig) gin.HandlerFunc { } // 表单数据 inputValue := reflect.ValueOf(formValue) + // 注入公共参数 if err = s.injectCommonParam(ctx, inputValue); nil != err { e = exception.NewFromError(500, err) @@ -73,6 +75,9 @@ func (s *server) RequestHandler(uriCfg UriConfig) gin.HandlerFunc { return } + // 非必传参数设置默认值 + defaults.SetDefaults(formValue) + isSuccess := false // 初始化响应之后logic logicAfterResponse := &define.LogicAfterResponse{