Merge remote-tracking branch 'gva/main'
# Conflicts: # server/go.mod # server/go.sum # server/mcp/api_creator.go # server/mcp/execution_plan_schema.md # server/mcp/gva_auto_generate.go # server/mcp/menu_creator.go # server/mcp/requirement_analyzer.go # server/utils/verify.go
This commit is contained in:
@@ -46,7 +46,8 @@ func GenerateField(field systemReq.AutoCodeField) string {
|
||||
|
||||
gormTag += "column:" + field.ColumnName + ";"
|
||||
|
||||
if field.DataTypeLong != "" && field.FieldType != "enum" {
|
||||
// 对于int类型,根据DataTypeLong决定具体的Go类型,不使用size标签
|
||||
if field.DataTypeLong != "" && field.FieldType != "enum" && field.FieldType != "int" {
|
||||
gormTag += fmt.Sprintf("size:%s;", field.DataTypeLong)
|
||||
}
|
||||
|
||||
@@ -85,8 +86,27 @@ func GenerateField(field systemReq.AutoCodeField) string {
|
||||
tagContent := fmt.Sprintf(`json:"%s" form:"%s" gorm:"%s"`,
|
||||
field.FieldJson, field.FieldJson, gormTag)
|
||||
|
||||
// 对于int类型,根据DataTypeLong决定具体的Go类型
|
||||
var fieldType string
|
||||
if field.FieldType == "int" {
|
||||
switch field.DataTypeLong {
|
||||
case "1", "2", "3":
|
||||
fieldType = "int8"
|
||||
case "4", "5":
|
||||
fieldType = "int16"
|
||||
case "6", "7", "8", "9", "10":
|
||||
fieldType = "int32"
|
||||
case "11", "12", "13", "14", "15", "16", "17", "18", "19", "20":
|
||||
fieldType = "int64"
|
||||
default:
|
||||
fieldType = "int64"
|
||||
}
|
||||
} else {
|
||||
fieldType = field.FieldType
|
||||
}
|
||||
|
||||
result = fmt.Sprintf(`%s *%s `+"`"+`%s`+"`"+``,
|
||||
field.FieldName, field.FieldType, tagContent)
|
||||
field.FieldName, fieldType, tagContent)
|
||||
}
|
||||
|
||||
if field.Require {
|
||||
@@ -222,11 +242,11 @@ func GenerateSearchFormItem(field systemReq.AutoCodeField) string {
|
||||
`
|
||||
} else if field.FieldType == "float64" || field.FieldType == "int" {
|
||||
if field.FieldSearchType == "BETWEEN" || field.FieldSearchType == "NOT BETWEEN" {
|
||||
result += fmt.Sprintf(` <el-input class="w-40" v-model.number="searchInfo.start%s" placeholder="最小值" />
|
||||
result += fmt.Sprintf(` <el-input class="!w-40" v-model.number="searchInfo.start%s" placeholder="最小值" />
|
||||
`, field.FieldName)
|
||||
result += ` —
|
||||
`
|
||||
result += fmt.Sprintf(` <el-input class="w-40" v-model.number="searchInfo.end%s" placeholder="最大值" />
|
||||
result += fmt.Sprintf(` <el-input class="!w-40" v-model.number="searchInfo.end%s" placeholder="最大值" />
|
||||
`, field.FieldName)
|
||||
} else {
|
||||
result += fmt.Sprintf(` <el-input v-model.number="searchInfo.%s" placeholder="搜索条件" />
|
||||
@@ -250,7 +270,7 @@ func GenerateSearchFormItem(field systemReq.AutoCodeField) string {
|
||||
`
|
||||
result += ` </template>
|
||||
`
|
||||
result += fmt.Sprintf(`<el-date-picker class="w-[380px]" v-model="searchInfo.%sRange" type="datetimerange" range-separator="至" start-placeholder="开始时间" end-placeholder="结束时间"></el-date-picker>`, field.FieldJson)
|
||||
result += fmt.Sprintf(`<el-date-picker class="!w-380px" v-model="searchInfo.%sRange" type="datetimerange" range-separator="至" start-placeholder="开始时间" end-placeholder="结束时间"></el-date-picker>`, field.FieldJson)
|
||||
} else {
|
||||
result += fmt.Sprintf(`<el-date-picker v-model="searchInfo.%s" type="datetime" placeholder="搜索条件"></el-date-picker>`, field.FieldJson)
|
||||
}
|
||||
|
||||
@@ -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()}}
|
||||
|
||||
Reference in New Issue
Block a user