From b93c7726f287b44dc3d14ac5a271d5ac915c2ed2 Mon Sep 17 00:00:00 2001 From: Rogee Date: Thu, 11 Sep 2025 19:28:51 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=9B=B4=E6=96=B0=20@Bind=20=E6=B3=A8?= =?UTF-8?q?=E9=87=8A=E8=AF=AD=E6=B3=95=EF=BC=8C=E7=A7=BB=E9=99=A4=20table?= =?UTF-8?q?=20=E5=8F=82=E6=95=B0=EF=BC=8C=E4=BC=98=E5=8C=96=E6=96=87?= =?UTF-8?q?=E6=A1=A3=E5=86=85=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkg/ast/route/route.go | 19 ++++++++----------- templates/project/README.md.raw | 6 +++--- 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/pkg/ast/route/route.go b/pkg/ast/route/route.go index 9c653ba..2473b7b 100644 --- a/pkg/ast/route/route.go +++ b/pkg/ast/route/route.go @@ -29,12 +29,11 @@ type ActionDefinition struct { } type ParamDefinition struct { - Name string - Type string - Key string - Table string - Model string - Position Position + Name string + Type string + Key string + Model string + Position Position } type Position string @@ -252,11 +251,9 @@ func parseRouteBind(bind string) ParamDefinition { param.Position = positionFromString(parts[i+2]) case "key": param.Key = parts[i+1] - case "table": - param.Table = parts[i+1] - case "model": - param.Model = parts[i+1] - } + case "model": + param.Model = parts[i+1] + } } return param } diff --git a/templates/project/README.md.raw b/templates/project/README.md.raw index b0de2ec..1cd18ce 100644 --- a/templates/project/README.md.raw +++ b/templates/project/README.md.raw @@ -10,10 +10,10 @@ - `@Router []` - 例如:`@Router /users/:id [get]` -- `@Bind [key()] [table()] [model()]` + - `@Bind [key()] [model()]` - `paramName` 必须与方法参数名一致(大小写敏感) - `position` 取值:`path`、`query`、`body`、`header`、`cookie`、`local`、`file` - - 可选:`key()` 为覆盖默认键名;`table()`、`model()` 解析并保留,当前不参与渲染(为后续扩展预留) + - 可选:`key()` 为覆盖默认键名;`model()` 解析并保留,当前不参与渲染(为后续扩展预留) ### 参数来源与绑定生成 @@ -86,5 +86,5 @@ router.Get("/users/:id", DataFunc4( ### 错误与限制 - 无效的 `@Router` 语法会报错;无效的 `position` 会在解析阶段触发错误。 -- `file` 目前仅支持单文件头;`table()`、`model()` 尚未参与代码生成。 +- `file` 目前仅支持单文件头;`model()` 尚未参与代码生成。 - 请与实际路由段保持一致(特别是 `path` 的 `key` 与路径变量名)。