完成结构体拼接
This commit is contained in:
parent
d49f21dd30
commit
f6db0286a2
@ -8,7 +8,6 @@
|
||||
package sql2go
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"git.zhangdeman.cn/zhangdeman/gopkg/util"
|
||||
@ -37,6 +36,8 @@ func ParseCreateTableSql(sql string) (string, error) {
|
||||
}
|
||||
|
||||
r := stmt.(*sqlparser.DDL)
|
||||
structResult := "type " + util.SnakeCaseToCamel(sqlparser.String(r.NewName)) + " struct { \n"
|
||||
|
||||
for _, item := range r.TableSpec.Columns {
|
||||
data := map[string]string{
|
||||
"{FIELD}": util.SnakeCaseToCamel(item.Name.String()),
|
||||
@ -56,7 +57,8 @@ func ParseCreateTableSql(sql string) (string, error) {
|
||||
for k, v := range data {
|
||||
val = strings.ReplaceAll(val, k, v)
|
||||
}
|
||||
fmt.Println(val)
|
||||
structResult += val + "\n"
|
||||
}
|
||||
return "", nil
|
||||
structResult = structResult + "}"
|
||||
return structResult, nil
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user