From 9f958addc89af8d9e201f7d83eb9ad3bf64e9625 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?piexlMax=28=E5=A5=87=E6=B7=BC?= Date: Wed, 6 Aug 2025 15:18:03 +0800 Subject: [PATCH] =?UTF-8?q?fix(verify):=20=E7=A7=BB=E9=99=A4=E7=99=BB?= =?UTF-8?q?=E5=BD=95=E9=AA=8C=E8=AF=81=E4=B8=AD=E7=9A=84Captcha=E5=AD=97?= =?UTF-8?q?=E6=AE=B5=E6=A0=A1=E9=AA=8C=20refactor(validation):=20=E5=BC=BA?= =?UTF-8?q?=E5=88=B6=E5=AD=97=E6=AE=B5=E5=90=8D=E9=A6=96=E5=AD=97=E6=AF=8D?= =?UTF-8?q?=E5=A4=A7=E5=86=99=E5=B9=B6=E6=9B=B4=E6=96=B0=E6=96=87=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/mcp/gva_auto_generate.go | 10 +++++++++- server/utils/verify.go | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/server/mcp/gva_auto_generate.go b/server/mcp/gva_auto_generate.go index a710567c..6c48a14e 100644 --- a/server/mcp/gva_auto_generate.go +++ b/server/mcp/gva_auto_generate.go @@ -173,7 +173,7 @@ func (t *AutomationModuleAnalyzer) New() mcp.Tool { "generateWeb": "是否生成前端(bool)", "generateServer": "是否生成后端(bool)", "fields": [{ - "fieldName": "字段名(string)", + "fieldName": "字段名(string)必须大写开头", "fieldDesc": "字段描述(string)", "fieldType": "字段类型支持:string(字符串),richtext(富文本),int(整型),bool(布尔值),float64(浮点型),time.Time(时间),enum(枚举),picture(单图片,字符串),pictures(多图片,json字符串),video(视频,字符串),file(文件,json字符串),json(JSON),array(数组)", "fieldJson": "JSON标签(string)", @@ -1243,6 +1243,14 @@ func (t *AutomationModuleAnalyzer) validateExecutionPlan(plan *ExecutionPlan) er if field.FieldName == "" { return fmt.Errorf("模块 %d 字段 %d 的 fieldName 不能为空", moduleIndex+1, i+1) } + + // 确保字段名首字母大写 + if len(field.FieldName) > 0 { + firstChar := string(field.FieldName[0]) + if firstChar >= "a" && firstChar <= "z" { + moduleInfo.Fields[i].FieldName = strings.ToUpper(firstChar) + field.FieldName[1:] + } + } if field.FieldDesc == "" { return fmt.Errorf("模块 %d 字段 %d 的 fieldDesc 不能为空", moduleIndex+1, i+1) } diff --git a/server/utils/verify.go b/server/utils/verify.go index e81c1f19..cc2cb78e 100644 --- a/server/utils/verify.go +++ b/server/utils/verify.go @@ -5,7 +5,7 @@ var ( ApiVerify = Rules{"Path": {NotEmpty()}, "Description": {NotEmpty()}, "ApiGroup": {NotEmpty()}, "Method": {NotEmpty()}} MenuVerify = Rules{"Path": {NotEmpty()}, "Name": {NotEmpty()}, "Component": {NotEmpty()}, "Sort": {Ge("0")}} MenuMetaVerify = Rules{"Title": {NotEmpty()}} - LoginVerify = Rules{"CaptchaId": {NotEmpty()}, "Captcha": {NotEmpty()}, "Username": {NotEmpty()}, "Password": {NotEmpty()}} + LoginVerify = Rules{"Username": {NotEmpty()}, "Password": {NotEmpty()}} RegisterVerify = Rules{"Username": {NotEmpty()}, "NickName": {NotEmpty()}, "Password": {NotEmpty()}, "AuthorityId": {NotEmpty()}} PageInfoVerify = Rules{"Page": {NotEmpty()}, "PageSize": {NotEmpty()}} CustomerVerify = Rules{"CustomerName": {NotEmpty()}, "CustomerPhoneData": {NotEmpty()}}