From bd01c39fcc429fceae9b656e7a0cd6b983559b3a 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, 7 Feb 2025 18:16:34 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=82=E6=95=B0=E8=A7=A3=E6=9E=90=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E8=A7=A3=E6=9E=90=E6=A0=87=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- router/controller.go | 5 +++++ router/define.go | 1 + 2 files changed, 6 insertions(+) diff --git a/router/controller.go b/router/controller.go index 22ec1cf..584b499 100644 --- a/router/controller.go +++ b/router/controller.go @@ -158,9 +158,14 @@ func (c controller) parseParamConfig(formDataType reflect.Type) []UriParam { if len(validate) == 0 { validate = strings.TrimSpace(structField.Tag.Get(TagNameValidate)) } + title := strings.TrimSpace(structField.Tag.Get(TagNameDesc)) + if len(title) == 0 { + title = jsonTag + } res = append(res, UriParam{ Field: structField.Name, Name: jsonTag, + Title: title, Type: structField.Type.String(), Validate: validate, ErrorMsg: "", diff --git a/router/define.go b/router/define.go index b8121f7..aef742d 100644 --- a/router/define.go +++ b/router/define.go @@ -53,6 +53,7 @@ type UriConfig struct { type UriParam struct { Field string `json:"field"` // 结构体字段 Name string `json:"name"` // 参数名称 + Title string `json:"title"` // 参数标题 Type string `json:"type"` // 参数类型 Validate string `json:"validate"` // 验证规则: validator/v10 库 ErrorMsg string `json:"error_msg"` // 验证失败的错误信息