Commit a13e6a08 authored by jianhua.zhang's avatar jianhua.zhang

1.生成结构体按照驼峰命名法

2.添加sql映射结构体类型
parent 8dc8664b
...@@ -77,10 +77,11 @@ func QueryTables() { ...@@ -77,10 +77,11 @@ func QueryTables() {
func Report() { func Report() {
fmt.Println("》》............................映射结构体开始............................》》") fmt.Println("》》............................映射结构体开始............................》》")
for tableName, ctMap := range queryResult { for tableName, ctMap := range queryResult {
goRes.Write("\ntype %s struct {\n", tableName) structName := CamelCase(tableName)
goRes.Write("\ntype %s struct {\n", structName)
tsRes.Write("\nexport class %s {\n", tableName) tsRes.Write("\nexport class %s {\n", tableName)
record := "type " record := "type "
record += tableName record += structName
record += "\t struct {\n" record += "\t struct {\n"
for colName, coltype := range ctMap { for colName, coltype := range ctMap {
//translate to go struct foramt //translate to go struct foramt
...@@ -119,7 +120,7 @@ func CamelCase(field string) string { ...@@ -119,7 +120,7 @@ func CamelCase(field string) string {
ret += strings.ToUpper(arr[str][0:1]) + arr[str][1:] ret += strings.ToUpper(arr[str][0:1]) + arr[str][1:]
} }
} else { } else {
return field return strings.ToUpper(field[0:1]) + field[1:]
} }
return ret return ret
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment