From 5266255f3575a36afc13430e94d1fa928bd42676 Mon Sep 17 00:00:00 2001 From: jager Date: Wed, 21 Feb 2024 17:39:53 +0800 Subject: [PATCH] store --- .coveralls.yml | 0 .gitattributes | 0 .github/FUNDING.yml | 0 .github/workflows/go.yml | 0 .gitignore | 1 + .travis.yml | 0 FUNDING.yml | 0 LICENSE | 0 Makefile | 2 +- README.md | 0 README_zh_cn.md | 0 config.yml | 66 ++-- data/cmd/cmd.go | 0 data/config/MyIni.go | 16 +- data/config/common.go | 0 data/config/test_def.go | 0 data/dlg/cmd_darwin.go | 0 data/dlg/cmd_linux.go | 0 data/dlg/cmd_windows.go | 0 data/dlg/common.go | 6 +- data/dlg/cui.go | 0 data/dlg/def.go | 0 data/dlg/i18n.go | 0 data/dlg/mycui.go | 0 data/view/cnf/def.go | 0 data/view/generate/def.go | 0 data/view/generate/generate.go | 0 data/view/genfunc/def.go | 26 ++ data/view/genfunc/genfunc.go | 0 data/view/genfunc/genfunc_test.go | 0 data/view/genfunc/model/gen.base.go | 0 data/view/genfunc/model/matrix.gen.account.go | 0 data/view/genfunc/model/matrix.gen.user.go | 0 data/view/genfunc/model/matrix.go | 0 data/view/genfunc/model/matrix.sql | 0 data/view/genstruct/common.go | 14 +- data/view/genstruct/def.go | 2 +- data/view/gtools/gtools.go | 12 +- data/view/gtools/gtools_test.go | 2 +- data/view/model/def.go | 0 data/view/model/def_ifs.go | 0 data/view/model/gencnf/gencnf.go | 0 data/view/model/genmssql/common.go | 100 ------ data/view/model/genmssql/def.go | 46 --- data/view/model/genmssql/genmssql.go | 257 --------------- data/view/model/genmysql/common.go | 0 data/view/model/genmysql/def.go | 0 data/view/model/genmysql/genmysql.go | 0 data/view/model/gensqlite/common.go | 96 ------ data/view/model/gensqlite/def.go | 32 -- data/view/model/gensqlite/gensqlite.go | 205 ------------ data/view/model/model_test.go | 2 +- doc/export.md | 0 doc/export_cn.md | 0 doc/func.md | 0 doc/func_cn.md | 0 go.mod | 4 +- go.sum | 23 +- gogenerate.go | 0 image/.DS_Store | Bin 8196 -> 8196 bytes image/gormt/1.png | Bin image/gormt/2.jpg | Bin image/gormt/3.jpg | Bin image/gormt/4.jpg | Bin image/gormt/out.gif | Bin image/gormt/ui_cn.gif | Bin image/gormt/ui_en.gif | Bin jc_payment_withdraw.go | 311 ++++++++++++++++++ main.go | 0 main_test.go | 4 +- prompt.go | 31 ++ sql.yml | 0 72 files changed, 432 insertions(+), 826 deletions(-) mode change 100644 => 100755 .coveralls.yml mode change 100644 => 100755 .gitattributes mode change 100644 => 100755 .github/FUNDING.yml mode change 100644 => 100755 .github/workflows/go.yml mode change 100644 => 100755 .gitignore mode change 100644 => 100755 .travis.yml mode change 100644 => 100755 FUNDING.yml mode change 100644 => 100755 LICENSE mode change 100644 => 100755 Makefile mode change 100644 => 100755 README.md mode change 100644 => 100755 README_zh_cn.md mode change 100644 => 100755 config.yml mode change 100644 => 100755 data/cmd/cmd.go mode change 100644 => 100755 data/config/MyIni.go mode change 100644 => 100755 data/config/common.go mode change 100644 => 100755 data/config/test_def.go mode change 100644 => 100755 data/dlg/cmd_darwin.go mode change 100644 => 100755 data/dlg/cmd_linux.go mode change 100644 => 100755 data/dlg/cmd_windows.go mode change 100644 => 100755 data/dlg/common.go mode change 100644 => 100755 data/dlg/cui.go mode change 100644 => 100755 data/dlg/def.go mode change 100644 => 100755 data/dlg/i18n.go mode change 100644 => 100755 data/dlg/mycui.go mode change 100644 => 100755 data/view/cnf/def.go mode change 100644 => 100755 data/view/generate/def.go mode change 100644 => 100755 data/view/generate/generate.go mode change 100644 => 100755 data/view/genfunc/genfunc.go mode change 100644 => 100755 data/view/genfunc/genfunc_test.go mode change 100644 => 100755 data/view/genfunc/model/gen.base.go mode change 100644 => 100755 data/view/genfunc/model/matrix.gen.account.go mode change 100644 => 100755 data/view/genfunc/model/matrix.gen.user.go mode change 100644 => 100755 data/view/genfunc/model/matrix.go mode change 100644 => 100755 data/view/genfunc/model/matrix.sql mode change 100644 => 100755 data/view/genstruct/common.go mode change 100644 => 100755 data/view/genstruct/def.go mode change 100644 => 100755 data/view/gtools/gtools.go mode change 100644 => 100755 data/view/gtools/gtools_test.go mode change 100644 => 100755 data/view/model/def.go mode change 100644 => 100755 data/view/model/def_ifs.go mode change 100644 => 100755 data/view/model/gencnf/gencnf.go delete mode 100644 data/view/model/genmssql/common.go delete mode 100644 data/view/model/genmssql/def.go delete mode 100644 data/view/model/genmssql/genmssql.go mode change 100644 => 100755 data/view/model/genmysql/common.go mode change 100644 => 100755 data/view/model/genmysql/def.go mode change 100644 => 100755 data/view/model/genmysql/genmysql.go delete mode 100644 data/view/model/gensqlite/common.go delete mode 100644 data/view/model/gensqlite/def.go delete mode 100644 data/view/model/gensqlite/gensqlite.go mode change 100644 => 100755 data/view/model/model_test.go mode change 100644 => 100755 doc/export.md mode change 100644 => 100755 doc/export_cn.md mode change 100644 => 100755 doc/func.md mode change 100644 => 100755 doc/func_cn.md mode change 100644 => 100755 go.mod mode change 100644 => 100755 go.sum mode change 100644 => 100755 gogenerate.go mode change 100644 => 100755 image/.DS_Store mode change 100644 => 100755 image/gormt/1.png mode change 100644 => 100755 image/gormt/2.jpg mode change 100644 => 100755 image/gormt/3.jpg mode change 100644 => 100755 image/gormt/4.jpg mode change 100644 => 100755 image/gormt/out.gif mode change 100644 => 100755 image/gormt/ui_cn.gif mode change 100644 => 100755 image/gormt/ui_en.gif create mode 100755 jc_payment_withdraw.go mode change 100644 => 100755 main.go mode change 100644 => 100755 main_test.go create mode 100755 prompt.go mode change 100644 => 100755 sql.yml diff --git a/.coveralls.yml b/.coveralls.yml old mode 100644 new mode 100755 diff --git a/.gitattributes b/.gitattributes old mode 100644 new mode 100755 diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml old mode 100644 new mode 100755 diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml old mode 100644 new mode 100755 diff --git a/.gitignore b/.gitignore old mode 100644 new mode 100755 index b237734..c15f85f --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,4 @@ db/oauth_db.go gormt.yml gormt /vendor +.DS_Store \ No newline at end of file diff --git a/.travis.yml b/.travis.yml old mode 100644 new mode 100755 diff --git a/FUNDING.yml b/FUNDING.yml old mode 100644 new mode 100755 diff --git a/LICENSE b/LICENSE old mode 100644 new mode 100755 diff --git a/Makefile b/Makefile old mode 100644 new mode 100755 index d057416..5f58b72 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -all: # 构建 +makeall: # 构建 make tar windows: CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -ldflags "-s -w" -o gormt.exe main.go diff --git a/README.md b/README.md old mode 100644 new mode 100755 diff --git a/README_zh_cn.md b/README_zh_cn.md old mode 100644 new mode 100755 diff --git a/config.yml b/config.yml old mode 100644 new mode 100755 index 5a36dcc..73b3d18 --- a/config.yml +++ b/config.yml @@ -1,46 +1,32 @@ base: - is_dev : false -out_dir : ./model # 输出目录 -url_tag : json # web url tag(json,db(https://github.com/google/go-querystring)) -language : # 语言(English,中 文) -db_tag : gorm # 数据库标签名(gorm,db) -simple : true # 简单输出(默认只输出gorm主键和字段标签) -user_gorm_model : false # model是否使用gorm.Model -is_db_tag : true # 是否输出 数据库标签(gorm,db) -is_out_sql : false # 是否输出 sql 原信息 -is_out_func : true # 是否输出 快捷函数 -is_web_tag : true # 是否打web标记(json标记前提条件) -is_web_tag_pk_hidden: true # web标记是否隐藏主键 -is_foreign_key : true # 是否导出外键关联 -is_gui : false # 是否ui模式显示 -is_table_name : true # 是否直接生成表名 -is_column_name : true # 是否直接生成列名 -is_null_to_point : false # 数据库默认 'DEFAULT NULL' 时设置结构为指针类型 -is_null_to_sql_null: false # 数据库默认 'DEFAULT NULL' 时设置结构为sql.NULL is_null_to_point如果为true,则is_null_to_sql_null不生效 -table_prefix : "" # 表前缀, 如果有则使用, 没有留空(如果表前缀以"-"开头,则表示去掉该前缀,struct、文件名都会去掉该前缀) -table_names: "" # 指定表生成,多个表用,隔开 -is_out_file_by_table_name: false # 是否根据表名生成多个model -is_out_page: true # 是否输出分页函数 - + is_dev: false +out_dir: . # 输出目录 +url_tag: json # web url tag(json,db(https://github.com/google/go-querystring)) +is_web_tag: true # 是否打web标记(json标记前提条件) +language: 中文 # 语言(English,中文) +db_tag: gorm # 数据库标签(gorm,db) +simple: false # 简单输出(默认gorm标签不输出) +user_gorm_model: true # model是否使用gorm.Model +is_out_sql: false # 是否输出 sql 原信息 +is_out_func: false # 是否输出 快捷函数 +is_foreign_key: false # 是否导出外键关联 +is_gui: false # 是否ui模式显示 +is_table_name: true # 是否直接生成表名,列名 +is_null_to_point: false # 数据库默认 'DEFAULT NULL' 时设置结构为指针类型 +is_web_tag_pk_hidden: false +table_prefix: "" #表前缀 +table_names: "jc_payment_withdraw" #指定表生成,多个表用,隔开 +is_column_name: true # 是否生成列名 +is_out_file_by_table_name: true # 是否根据表名生成多个model db_info: - host : 127.0.0.1 # type=1的时候,host为yml文件全路径 - port : 3306 - username : root - password : 123456 - database : matrix + host: 127.0.0.1 + port: 3306 + username: root + password: "joint.jager.168" + database: "game_center" type: 0 # 数据库类型:0:mysql , 1:sqlite , 2:mssql self_type_define: # 自定义数据类型映射 datetime: time.Time - time: time.Time - ^(int)[(]\d+[)]: int + date: time.Time out_file_name: "" # 自定义生成文件名 -web_tag_type: 0 # json tag类型 0: 小驼峰 1: 下划线 - -# sqlite -# db_info: -# host : /Users/xxj/Downloads/caoguo # type=1的时候,host为yml文件全路径 -# port : -# username : -# password : -# database : -# type: 1 # 数据库类型:0:mysql , 1:sqlite , 2:mssql \ No newline at end of file +web_tag_type: 1 # json tag类型 0: 小驼峰 1: 下划线 diff --git a/data/cmd/cmd.go b/data/cmd/cmd.go old mode 100644 new mode 100755 diff --git a/data/config/MyIni.go b/data/config/MyIni.go old mode 100644 new mode 100755 index 869fdef..05fa212 --- a/data/config/MyIni.go +++ b/data/config/MyIni.go @@ -81,12 +81,12 @@ func GetOutDir() string { return _map.OutDir } -// // SetSingularTable Set Disabled Table Name Plurals.设置禁用表名复数 +// // SetSingularTable Set Disabled Table ChainType Plurals.设置禁用表名复数 // func SetSingularTable(b bool) { // _map.SingularTable = b // } -// // GetSingularTable Get Disabled Table Name Plurals.获取禁用表名复数 +// // GetSingularTable Get Disabled Table ChainType Plurals.获取禁用表名复数 // func GetSingularTable() bool { // return _map.SingularTable // } @@ -275,7 +275,7 @@ func GetWebTagType() int { return _map.WebTagType } -//GetTableNames get format tableNames by config. 获取格式化后设置的表名 +// GetTableNames get format tableNames by config. 获取格式化后设置的表名 func GetTableNames() string { var sb strings.Builder if _map.TableNames != "" { @@ -302,27 +302,27 @@ func GetTableNames() string { return sb.String() } -//GetOriginTableNames get origin tableNames. 获取原始的设置的表名 +// GetOriginTableNames get origin tableNames. 获取原始的设置的表名 func GetOriginTableNames() string { return _map.TableNames } -//SetTableNames set tableNames. 设置生成的表名 +// SetTableNames set tableNames. 设置生成的表名 func SetTableNames(tableNames string) { _map.TableNames = tableNames } -//GetIsColumnName get gen columnName config . 获取生成列名的config +// GetIsColumnName get gen columnName config . 获取生成列名的config func GetIsColumnName() bool { return _map.IsColumnName } -//SetIsColumnName set gen ColumnName config. 设置生成列名的config +// SetIsColumnName set gen ColumnName config. 设置生成列名的config func SetIsColumnName(isColumnName bool) { _map.IsColumnName = isColumnName } -//GetIsOutFileByTableName get gen columnName config . 设置是否根据表名生成文件 +// GetIsOutFileByTableName get gen columnName config . 设置是否根据表名生成文件 func GetIsOutFileByTableName() bool { return _map.IsOutFileByTableName } diff --git a/data/config/common.go b/data/config/common.go old mode 100644 new mode 100755 diff --git a/data/config/test_def.go b/data/config/test_def.go old mode 100644 new mode 100755 diff --git a/data/dlg/cmd_darwin.go b/data/dlg/cmd_darwin.go old mode 100644 new mode 100755 diff --git a/data/dlg/cmd_linux.go b/data/dlg/cmd_linux.go old mode 100644 new mode 100755 diff --git a/data/dlg/cmd_windows.go b/data/dlg/cmd_windows.go old mode 100644 new mode 100755 diff --git a/data/dlg/common.go b/data/dlg/common.go old mode 100644 new mode 100755 index 590fbee..554beac --- a/data/dlg/common.go +++ b/data/dlg/common.go @@ -7,7 +7,7 @@ import ( "github.com/jroimartin/gocui" "github.com/xxjwxc/gormt/data/view/model" "github.com/xxjwxc/gormt/data/view/model/genmysql" - "github.com/xxjwxc/gormt/data/view/model/gensqlite" + //"github.com/xxjwxc/gormt/data/view/model/gensqlite" "github.com/xxjwxc/gormt/data/config" @@ -79,8 +79,8 @@ func generate(g *gocui.Gui, v *gocui.View) { switch config.GetDbInfo().Type { case 0: modeldb = genmysql.GetModel() - case 1: - modeldb = gensqlite.GetModel() + //case 1: + // modeldb = gensqlite.GetModel() } if modeldb == nil { mylog.Error(fmt.Errorf("modeldb not fund : please check db_info.type (0:mysql , 1:sqlite , 2:mssql) ")) diff --git a/data/dlg/cui.go b/data/dlg/cui.go old mode 100644 new mode 100755 diff --git a/data/dlg/def.go b/data/dlg/def.go old mode 100644 new mode 100755 diff --git a/data/dlg/i18n.go b/data/dlg/i18n.go old mode 100644 new mode 100755 diff --git a/data/dlg/mycui.go b/data/dlg/mycui.go old mode 100644 new mode 100755 diff --git a/data/view/cnf/def.go b/data/view/cnf/def.go old mode 100644 new mode 100755 diff --git a/data/view/generate/def.go b/data/view/generate/def.go old mode 100644 new mode 100755 diff --git a/data/view/generate/generate.go b/data/view/generate/generate.go old mode 100644 new mode 100755 diff --git a/data/view/genfunc/def.go b/data/view/genfunc/def.go index 52486ee..86e3aba 100755 --- a/data/view/genfunc/def.go +++ b/data/view/genfunc/def.go @@ -8,6 +8,32 @@ func (m *{{.StructName}}) TableName() string { } ` genColumn = ` +type I{{.StructName}} interface { +{{range $em := .Em}} + Get{{$em.StructName}}() {{$em.Type}}{{end}} +} + +{{$module := .StructName}} +{{range $em := .Em}} +func (m *{{$module}}) Get{{$em.StructName}}() {{$em.Type}} { + return m.{{$em.StructName}} +} +{{end}} + +// ToMap struct to map 结构体转成map +func (m *{{.StructName}}) ToMap() map[string]any { + return map[string]any{ {{range $em := .Em}} + "{{$em.ColumnName}}":m.{{$em.StructName}}, {{end}} + } +} + +// ToMapWithoutModel struct to map 结构体转成map, 不带gorm.Model +func (m *{{.StructName}}) ToMapWithoutModel() map[string]any { + return map[string]any{ {{range $em := .Em}} {{ if and (ne $em.ColumnName "id") (ne $em.ColumnName "created_at") (ne $em.ColumnName "updated_at") (ne $em.ColumnName "deleted_at") }} + "{{$em.ColumnName}}":m.{{$em.StructName}}, {{end}}{{end}} + } +} + // {{.StructName}}Columns get sql column name.获取数据库列名 var {{.StructName}}Columns = struct { {{range $em := .Em}} {{$em.StructName}} string{{end}} diff --git a/data/view/genfunc/genfunc.go b/data/view/genfunc/genfunc.go old mode 100644 new mode 100755 diff --git a/data/view/genfunc/genfunc_test.go b/data/view/genfunc/genfunc_test.go old mode 100644 new mode 100755 diff --git a/data/view/genfunc/model/gen.base.go b/data/view/genfunc/model/gen.base.go old mode 100644 new mode 100755 diff --git a/data/view/genfunc/model/matrix.gen.account.go b/data/view/genfunc/model/matrix.gen.account.go old mode 100644 new mode 100755 diff --git a/data/view/genfunc/model/matrix.gen.user.go b/data/view/genfunc/model/matrix.gen.user.go old mode 100644 new mode 100755 diff --git a/data/view/genfunc/model/matrix.go b/data/view/genfunc/model/matrix.go old mode 100644 new mode 100755 diff --git a/data/view/genfunc/model/matrix.sql b/data/view/genfunc/model/matrix.sql old mode 100644 new mode 100755 diff --git a/data/view/genstruct/common.go b/data/view/genstruct/common.go old mode 100644 new mode 100755 index ec75e66..ca8fb07 --- a/data/view/genstruct/common.go +++ b/data/view/genstruct/common.go @@ -160,6 +160,7 @@ func (s *GenStruct) GenerateColumnName() []string { Em []struct { ColumnName string StructName string + Type string } } data.StructName = s.Name @@ -168,18 +169,21 @@ func (s *GenStruct) GenerateColumnName() []string { data.Em = append(data.Em, []struct { ColumnName string StructName string + Type string }{ - {ColumnName: "id", StructName: "ID"}, - {ColumnName: "created_at", StructName: "CreatedAt"}, - {ColumnName: "updated_at", StructName: "UpdatedAt"}, - {ColumnName: "deleted_at", StructName: "DeletedAt"}, + {ColumnName: "id", StructName: "ID", Type: "uint"}, + {ColumnName: "created_at", StructName: "CreatedAt", Type: "time.Time"}, + {ColumnName: "updated_at", StructName: "UpdatedAt", Type: "time.Time"}, + {ColumnName: "deleted_at", StructName: "DeletedAt", Type: "gorm.DeletedAt"}, }...) } else if len(v.ColumnName) > 0 { data.Em = append(data.Em, struct { ColumnName string StructName string + Type string }{ColumnName: v.ColumnName, StructName: v.Name, + Type: v.Type, }) } @@ -260,7 +264,7 @@ func (p *GenPackage) AddStruct(st GenStruct) { // Generate Get the result data.获取结果数据 func (p *GenPackage) Generate() string { p.genimport() // auto add import .补充 import - + p.AddImport(`"time"`) var pa generate.PrintAtom pa.Add("package", p.Name) // add import diff --git a/data/view/genstruct/def.go b/data/view/genstruct/def.go old mode 100644 new mode 100755 index b505fd7..c059ba5 --- a/data/view/genstruct/def.go +++ b/data/view/genstruct/def.go @@ -2,7 +2,7 @@ package genstruct // GenElement element of sturct.元素类 type GenElement struct { - Name string // Name.元素名 + Name string // ChainType.元素名 ColumnName string // table name.表名 Type string // Type.类型标记 Notes string // Notes.注释 diff --git a/data/view/gtools/gtools.go b/data/view/gtools/gtools.go old mode 100644 new mode 100755 index 91c935e..65d4d3e --- a/data/view/gtools/gtools.go +++ b/data/view/gtools/gtools.go @@ -11,9 +11,9 @@ import ( "github.com/xxjwxc/gormt/data/config" - "github.com/xxjwxc/gormt/data/view/model/genmssql" + //"github.com/xxjwxc/gormt/data/view/model/genmssql" "github.com/xxjwxc/gormt/data/view/model/genmysql" - "github.com/xxjwxc/gormt/data/view/model/gensqlite" + //"github.com/xxjwxc/gormt/data/view/model/gensqlite" "github.com/xxjwxc/public/tools" ) @@ -35,10 +35,10 @@ func showCmd() { switch config.GetDbInfo().Type { case 0: // mysql modeldb = genmysql.GetModel() - case 1: // sqllite - modeldb = gensqlite.GetModel() - case 2: // - modeldb = genmssql.GetModel() + //case 1: // sqllite + // modeldb = gensqlite.GetModel() + //case 2: // + // modeldb = genmssql.GetModel() } if modeldb == nil { mylog.Error(fmt.Errorf("modeldb not fund : please check db_info.type (0:mysql , 1:sqlite , 2:mssql) ")) diff --git a/data/view/gtools/gtools_test.go b/data/view/gtools/gtools_test.go old mode 100644 new mode 100755 index 5fdd392..d6039b3 --- a/data/view/gtools/gtools_test.go +++ b/data/view/gtools/gtools_test.go @@ -10,7 +10,7 @@ import ( // TestTools func TestTools(t *testing.T) { - str := `{"DbName":"oauth_db","PackageName":"model","TabList":[{"Name":"user_account_tbl","Notes":"用户账号","SQLBuildStr":"","Em":[{"Name":"id","Notes":"","Type":"int(11)","Index":[{"Key":1,"KeyName":""}],"IsNull":false,"ForeignKeyList":null},{"Name":"account","Notes":"","Type":"varchar(64)","Index":[{"Key":2,"KeyName":""}],"IsNull":false,"ForeignKeyList":null},{"Name":"password","Notes":"","Type":"varchar(64)","Index":null,"IsNull":false,"ForeignKeyList":null},{"Name":"account_type","Notes":"帐号类型:0手机号,1邮件","Type":"int(11)","Index":null,"IsNull":false,"ForeignKeyList":null},{"Name":"app_key","Notes":"authbucket_oauth2_client表的id","Type":"varchar(255)","Index":null,"IsNull":false,"ForeignKeyList":null},{"Name":"user_info_tbl_id","Notes":"","Type":"int(11)","Index":[{"Key":3,"KeyName":"user_info_id"}],"IsNull":false,"ForeignKeyList":[{"TableName":"user_info_tbl","ColumnName":"id"}]},{"Name":"reg_time","Notes":"","Type":"datetime","Index":null,"IsNull":true,"ForeignKeyList":null},{"Name":"reg_ip","Notes":"","Type":"varchar(15)","Index":[{"Key":3,"KeyName":"user_info_id"}],"IsNull":true,"ForeignKeyList":null},{"Name":"bundle_id","Notes":"","Type":"varchar(255)","Index":null,"IsNull":true,"ForeignKeyList":null},{"Name":"describ","Notes":"","Type":"varchar(255)","Index":null,"IsNull":true,"ForeignKeyList":null}]},{"Name":"user_info_tbl","Notes":"用户信息","SQLBuildStr":"","Em":[{"Name":"","Notes":"","Type":"gorm.Model","Index":null,"IsNull":false,"ForeignKeyList":null},{"Name":"nickname","Notes":"","Type":"varchar(32)","Index":null,"IsNull":false,"ForeignKeyList":null},{"Name":"headurl","Notes":"","Type":"varchar(255)","Index":null,"IsNull":true,"ForeignKeyList":null}]},{"Name":"oauth2_access_token","Notes":"token认证","SQLBuildStr":"","Em":[{"Name":"id","Notes":"","Type":"int(11)","Index":[{"Key":1,"KeyName":""}],"IsNull":false,"ForeignKeyList":null},{"Name":"access_token","Notes":"","Type":"varchar(255)","Index":[{"Key":2,"KeyName":""}],"IsNull":false,"ForeignKeyList":null},{"Name":"token_type","Notes":"","Type":"varchar(255)","Index":null,"IsNull":false,"ForeignKeyList":null},{"Name":"app_key","Notes":"key","Type":"varchar(255)","Index":null,"IsNull":false,"ForeignKeyList":null},{"Name":"username","Notes":"用户名","Type":"varchar(255)","Index":null,"IsNull":false,"ForeignKeyList":null},{"Name":"expires","Notes":"过期时间","Type":"datetime","Index":null,"IsNull":false,"ForeignKeyList":null}]},{"Name":"user","Notes":"","SQLBuildStr":"","Em":[{"Name":"userId","Notes":"","Type":"int(11)","Index":[{"Key":1,"KeyName":""}],"IsNull":false,"ForeignKeyList":null},{"Name":"name","Notes":"","Type":"varchar(30)","Index":null,"IsNull":false,"ForeignKeyList":null},{"Name":"sex","Notes":"","Type":"int(11)","Index":[{"Key":3,"KeyName":""}],"IsNull":false,"ForeignKeyList":null},{"Name":"job","Notes":"","Type":"int(11)","Index":null,"IsNull":false,"ForeignKeyList":null}]},{"Name":"organ","Notes":"","SQLBuildStr":"","Em":[{"Name":"id","Notes":"","Type":"int(11)","Index":[{"Key":1,"KeyName":""}],"IsNull":false,"ForeignKeyList":null},{"Name":"userId","Notes":"","Type":"int(11)","Index":[{"Key":3,"KeyName":""}],"IsNull":true,"ForeignKeyList":[{"TableName":"user","ColumnName":"sex"}]},{"Name":"type","Notes":"","Type":"int(11)","Index":null,"IsNull":true,"ForeignKeyList":null},{"Name":"score","Notes":"","Type":"int(11)","Index":null,"IsNull":true,"ForeignKeyList":null}]},{"Name":"sign_client_tbl","Notes":"","SQLBuildStr":"","Em":[{"Name":"id","Notes":"","Type":"int(11)","Index":[{"Key":1,"KeyName":""}],"IsNull":false,"ForeignKeyList":null},{"Name":"app_key","Notes":"","Type":"varchar(255)","Index":null,"IsNull":false,"ForeignKeyList":null},{"Name":"app_secret","Notes":"","Type":"varchar(255)","Index":null,"IsNull":false,"ForeignKeyList":null},{"Name":"expire_time","Notes":"超时时间","Type":"datetime","Index":null,"IsNull":false,"ForeignKeyList":null},{"Name":"strict_sign","Notes":"是否强制验签:0:用户自定义,1:强制","Type":"int(255)","Index":null,"IsNull":true,"ForeignKeyList":null},{"Name":"strict_verify","Notes":"是否强制验证码:0:用户自定义,1:强制","Type":"int(11)","Index":null,"IsNull":false,"ForeignKeyList":null},{"Name":"token_expire_time","Notes":"token过期时间","Type":"int(11)","Index":null,"IsNull":false,"ForeignKeyList":null}]},{"Name":"user_paybill_order","Notes":"","SQLBuildStr":"","Em":[{"Name":"id","Notes":"","Type":"int(11)","Index":[{"Key":1,"KeyName":""}],"IsNull":false,"ForeignKeyList":null},{"Name":"paybill_id","Notes":"二次账单id","Type":"bigint(20)","Index":[{"Key":3,"KeyName":"order_id"}],"IsNull":false,"ForeignKeyList":null},{"Name":"order_id_mysql","Notes":"MySql中的订单Id","Type":"bigint(20)","Index":[{"Key":3,"KeyName":"order_id"}],"IsNull":false,"ForeignKeyList":null},{"Name":"order_item_id_mysql","Notes":"MySql中的订单ItemId","Type":"bigint(20)","Index":[{"Key":3,"KeyName":"order_id"}],"IsNull":false,"ForeignKeyList":null},{"Name":"order_id_mssql","Notes":"MsSql中的订单Id","Type":"bigint(20)","Index":null,"IsNull":false,"ForeignKeyList":null}]},{"Name":"oauth2_client_tbl","Notes":"client key 信息","SQLBuildStr":"","Em":[{"Name":"id","Notes":"","Type":"int(11)","Index":[{"Key":1,"KeyName":""}],"IsNull":false,"ForeignKeyList":null},{"Name":"app_key","Notes":"","Type":"varchar(255)","Index":null,"IsNull":false,"ForeignKeyList":null},{"Name":"app_secret","Notes":"","Type":"varchar(255)","Index":null,"IsNull":false,"ForeignKeyList":null},{"Name":"expire_time","Notes":"超时时间","Type":"datetime","Index":null,"IsNull":false,"ForeignKeyList":null},{"Name":"strict_sign","Notes":"是否强制验签:0:用户自定义,1:强制","Type":"int(255)","Index":null,"IsNull":true,"ForeignKeyList":null},{"Name":"strict_verify","Notes":"是否强制验证码:0:用户自定义,1:强制","Type":"int(11)","Index":null,"IsNull":false,"ForeignKeyList":null},{"Name":"token_expire_time","Notes":"token过期时间","Type":"int(11)","Index":null,"IsNull":false,"ForeignKeyList":null},{"Name":"aaa","Notes":"","Type":"json","Index":null,"IsNull":true,"ForeignKeyList":null}]},{"Name":"oauth2_refresh_token","Notes":"刷新token","SQLBuildStr":"","Em":[{"Name":"id","Notes":"","Type":"int(11)","Index":[{"Key":1,"KeyName":""}],"IsNull":false,"ForeignKeyList":null},{"Name":"refresh_token","Notes":"","Type":"varchar(255)","Index":[{"Key":2,"KeyName":""}],"IsNull":false,"ForeignKeyList":null},{"Name":"token_type","Notes":"","Type":"varchar(255)","Index":null,"IsNull":false,"ForeignKeyList":null},{"Name":"app_key","Notes":"","Type":"varchar(255)","Index":null,"IsNull":false,"ForeignKeyList":null},{"Name":"username","Notes":"","Type":"varchar(255)","Index":null,"IsNull":false,"ForeignKeyList":null},{"Name":"expires","Notes":"","Type":"datetime","Index":null,"IsNull":false,"ForeignKeyList":null},{"Name":"token_expire_time","Notes":"","Type":"int(11)","Index":null,"IsNull":false,"ForeignKeyList":null}]}]}` + str := `{"DbName":"oauth_db","PackageName":"model","TabList":[{"ChainType":"user_account_tbl","Notes":"用户账号","SQLBuildStr":"","Em":[{"ChainType":"id","Notes":"","Type":"int(11)","Index":[{"Key":1,"KeyName":""}],"IsNull":false,"ForeignKeyList":null},{"ChainType":"account","Notes":"","Type":"varchar(64)","Index":[{"Key":2,"KeyName":""}],"IsNull":false,"ForeignKeyList":null},{"ChainType":"password","Notes":"","Type":"varchar(64)","Index":null,"IsNull":false,"ForeignKeyList":null},{"ChainType":"account_type","Notes":"帐号类型:0手机号,1邮件","Type":"int(11)","Index":null,"IsNull":false,"ForeignKeyList":null},{"ChainType":"app_key","Notes":"authbucket_oauth2_client表的id","Type":"varchar(255)","Index":null,"IsNull":false,"ForeignKeyList":null},{"ChainType":"user_info_tbl_id","Notes":"","Type":"int(11)","Index":[{"Key":3,"KeyName":"user_info_id"}],"IsNull":false,"ForeignKeyList":[{"TableName":"user_info_tbl","ColumnName":"id"}]},{"ChainType":"reg_time","Notes":"","Type":"datetime","Index":null,"IsNull":true,"ForeignKeyList":null},{"ChainType":"reg_ip","Notes":"","Type":"varchar(15)","Index":[{"Key":3,"KeyName":"user_info_id"}],"IsNull":true,"ForeignKeyList":null},{"ChainType":"bundle_id","Notes":"","Type":"varchar(255)","Index":null,"IsNull":true,"ForeignKeyList":null},{"ChainType":"describ","Notes":"","Type":"varchar(255)","Index":null,"IsNull":true,"ForeignKeyList":null}]},{"ChainType":"user_info_tbl","Notes":"用户信息","SQLBuildStr":"","Em":[{"ChainType":"","Notes":"","Type":"gorm.Model","Index":null,"IsNull":false,"ForeignKeyList":null},{"ChainType":"nickname","Notes":"","Type":"varchar(32)","Index":null,"IsNull":false,"ForeignKeyList":null},{"ChainType":"headurl","Notes":"","Type":"varchar(255)","Index":null,"IsNull":true,"ForeignKeyList":null}]},{"ChainType":"oauth2_access_token","Notes":"token认证","SQLBuildStr":"","Em":[{"ChainType":"id","Notes":"","Type":"int(11)","Index":[{"Key":1,"KeyName":""}],"IsNull":false,"ForeignKeyList":null},{"ChainType":"access_token","Notes":"","Type":"varchar(255)","Index":[{"Key":2,"KeyName":""}],"IsNull":false,"ForeignKeyList":null},{"ChainType":"token_type","Notes":"","Type":"varchar(255)","Index":null,"IsNull":false,"ForeignKeyList":null},{"ChainType":"app_key","Notes":"key","Type":"varchar(255)","Index":null,"IsNull":false,"ForeignKeyList":null},{"ChainType":"username","Notes":"用户名","Type":"varchar(255)","Index":null,"IsNull":false,"ForeignKeyList":null},{"ChainType":"expires","Notes":"过期时间","Type":"datetime","Index":null,"IsNull":false,"ForeignKeyList":null}]},{"ChainType":"user","Notes":"","SQLBuildStr":"","Em":[{"ChainType":"userId","Notes":"","Type":"int(11)","Index":[{"Key":1,"KeyName":""}],"IsNull":false,"ForeignKeyList":null},{"ChainType":"name","Notes":"","Type":"varchar(30)","Index":null,"IsNull":false,"ForeignKeyList":null},{"ChainType":"sex","Notes":"","Type":"int(11)","Index":[{"Key":3,"KeyName":""}],"IsNull":false,"ForeignKeyList":null},{"ChainType":"job","Notes":"","Type":"int(11)","Index":null,"IsNull":false,"ForeignKeyList":null}]},{"ChainType":"organ","Notes":"","SQLBuildStr":"","Em":[{"ChainType":"id","Notes":"","Type":"int(11)","Index":[{"Key":1,"KeyName":""}],"IsNull":false,"ForeignKeyList":null},{"ChainType":"userId","Notes":"","Type":"int(11)","Index":[{"Key":3,"KeyName":""}],"IsNull":true,"ForeignKeyList":[{"TableName":"user","ColumnName":"sex"}]},{"ChainType":"type","Notes":"","Type":"int(11)","Index":null,"IsNull":true,"ForeignKeyList":null},{"ChainType":"score","Notes":"","Type":"int(11)","Index":null,"IsNull":true,"ForeignKeyList":null}]},{"ChainType":"sign_client_tbl","Notes":"","SQLBuildStr":"","Em":[{"ChainType":"id","Notes":"","Type":"int(11)","Index":[{"Key":1,"KeyName":""}],"IsNull":false,"ForeignKeyList":null},{"ChainType":"app_key","Notes":"","Type":"varchar(255)","Index":null,"IsNull":false,"ForeignKeyList":null},{"ChainType":"app_secret","Notes":"","Type":"varchar(255)","Index":null,"IsNull":false,"ForeignKeyList":null},{"ChainType":"expire_time","Notes":"超时时间","Type":"datetime","Index":null,"IsNull":false,"ForeignKeyList":null},{"ChainType":"strict_sign","Notes":"是否强制验签:0:用户自定义,1:强制","Type":"int(255)","Index":null,"IsNull":true,"ForeignKeyList":null},{"ChainType":"strict_verify","Notes":"是否强制验证码:0:用户自定义,1:强制","Type":"int(11)","Index":null,"IsNull":false,"ForeignKeyList":null},{"ChainType":"token_expire_time","Notes":"token过期时间","Type":"int(11)","Index":null,"IsNull":false,"ForeignKeyList":null}]},{"ChainType":"user_paybill_order","Notes":"","SQLBuildStr":"","Em":[{"ChainType":"id","Notes":"","Type":"int(11)","Index":[{"Key":1,"KeyName":""}],"IsNull":false,"ForeignKeyList":null},{"ChainType":"paybill_id","Notes":"二次账单id","Type":"bigint(20)","Index":[{"Key":3,"KeyName":"order_id"}],"IsNull":false,"ForeignKeyList":null},{"ChainType":"order_id_mysql","Notes":"MySql中的订单Id","Type":"bigint(20)","Index":[{"Key":3,"KeyName":"order_id"}],"IsNull":false,"ForeignKeyList":null},{"ChainType":"order_item_id_mysql","Notes":"MySql中的订单ItemId","Type":"bigint(20)","Index":[{"Key":3,"KeyName":"order_id"}],"IsNull":false,"ForeignKeyList":null},{"ChainType":"order_id_mssql","Notes":"MsSql中的订单Id","Type":"bigint(20)","Index":null,"IsNull":false,"ForeignKeyList":null}]},{"ChainType":"oauth2_client_tbl","Notes":"client key 信息","SQLBuildStr":"","Em":[{"ChainType":"id","Notes":"","Type":"int(11)","Index":[{"Key":1,"KeyName":""}],"IsNull":false,"ForeignKeyList":null},{"ChainType":"app_key","Notes":"","Type":"varchar(255)","Index":null,"IsNull":false,"ForeignKeyList":null},{"ChainType":"app_secret","Notes":"","Type":"varchar(255)","Index":null,"IsNull":false,"ForeignKeyList":null},{"ChainType":"expire_time","Notes":"超时时间","Type":"datetime","Index":null,"IsNull":false,"ForeignKeyList":null},{"ChainType":"strict_sign","Notes":"是否强制验签:0:用户自定义,1:强制","Type":"int(255)","Index":null,"IsNull":true,"ForeignKeyList":null},{"ChainType":"strict_verify","Notes":"是否强制验证码:0:用户自定义,1:强制","Type":"int(11)","Index":null,"IsNull":false,"ForeignKeyList":null},{"ChainType":"token_expire_time","Notes":"token过期时间","Type":"int(11)","Index":null,"IsNull":false,"ForeignKeyList":null},{"ChainType":"aaa","Notes":"","Type":"json","Index":null,"IsNull":true,"ForeignKeyList":null}]},{"ChainType":"oauth2_refresh_token","Notes":"刷新token","SQLBuildStr":"","Em":[{"ChainType":"id","Notes":"","Type":"int(11)","Index":[{"Key":1,"KeyName":""}],"IsNull":false,"ForeignKeyList":null},{"ChainType":"refresh_token","Notes":"","Type":"varchar(255)","Index":[{"Key":2,"KeyName":""}],"IsNull":false,"ForeignKeyList":null},{"ChainType":"token_type","Notes":"","Type":"varchar(255)","Index":null,"IsNull":false,"ForeignKeyList":null},{"ChainType":"app_key","Notes":"","Type":"varchar(255)","Index":null,"IsNull":false,"ForeignKeyList":null},{"ChainType":"username","Notes":"","Type":"varchar(255)","Index":null,"IsNull":false,"ForeignKeyList":null},{"ChainType":"expires","Notes":"","Type":"datetime","Index":null,"IsNull":false,"ForeignKeyList":null},{"ChainType":"token_expire_time","Notes":"","Type":"int(11)","Index":null,"IsNull":false,"ForeignKeyList":null}]}]}` var pkg model.DBInfo json.Unmarshal([]byte(str), &pkg) // out, _ := json.Marshal(pkg) diff --git a/data/view/model/def.go b/data/view/model/def.go old mode 100644 new mode 100755 diff --git a/data/view/model/def_ifs.go b/data/view/model/def_ifs.go old mode 100644 new mode 100755 diff --git a/data/view/model/gencnf/gencnf.go b/data/view/model/gencnf/gencnf.go old mode 100644 new mode 100755 diff --git a/data/view/model/genmssql/common.go b/data/view/model/genmssql/common.go deleted file mode 100644 index 8f7d78b..0000000 --- a/data/view/model/genmssql/common.go +++ /dev/null @@ -1,100 +0,0 @@ -package genmssql - -import ( - "strings" - - "github.com/xxjwxc/gormt/data/config" - "github.com/xxjwxc/public/mylog" - - "github.com/xxjwxc/gormt/data/view/model" -) - -// filterModel filter.过滤 gorm.Model -func filterModel(list *[]genColumns) bool { - if config.GetDBTag() != "gorm" || !config.GetUserGormModel() { - return false - } - - var _temp []genColumns - num := 0 - for _, v := range *list { - if strings.EqualFold(v.Field, "id") || - strings.EqualFold(v.Field, "created_at") || - strings.EqualFold(v.Field, "updated_at") || - strings.EqualFold(v.Field, "deleted_at") { - num++ - } else { - _temp = append(_temp, v) - } - } - - if num >= 4 { - *list = _temp - return true - } - - return false -} - -// fixForeignKey fix foreign key.过滤外键 -func fixForeignKey(list []genForeignKey, columuName string, result *[]model.ForeignKey) { - for _, v := range list { - if strings.EqualFold(v.ColumnName, columuName) { // find it .找到了 - *result = append(*result, model.ForeignKey{ - TableName: v.ReferencedTableName, - ColumnName: v.ReferencedColumnName, - }) - } - } -} - -// GetModel get model interface. 获取model接口 -func GetModel() model.IModel { - //now just support mysql - return &MssqlModel -} - -// FixNotes 分析元素表注释 -func FixNotes(em *model.ColumnsInfo, note string) { - b0 := FixElementTag(em, note) // gorm - b1 := FixForeignKeyTag(em, em.Notes) // 外键 - if !b0 && b1 { // 补偿 - FixElementTag(em, em.Notes) // gorm - } -} - -// FixElementTag 分析元素表注释 -func FixElementTag(em *model.ColumnsInfo, note string) bool { - matches := noteRegex.FindStringSubmatch(note) - if len(matches) < 2 { - em.Notes = note - return false - } - - mylog.Infof("get one gorm tag:(%v) ==> (%v)", em.BaseInfo.Name, matches[1]) - em.Notes = note[len(matches[0]):] - em.Gormt = matches[1] - return true -} - -// FixForeignKeyTag 分析元素表注释(外键) -func FixForeignKeyTag(em *model.ColumnsInfo, note string) bool { - matches := foreignKeyRegex.FindStringSubmatch(note) // foreign key 外键 - if len(matches) < 2 { - em.Notes = note - return false - } - em.Notes = note[len(matches[0]):] - - // foreign key 外键 - tmp := strings.Split(matches[1], ".") - if len(tmp) > 0 { - mylog.Infof("get one foreign key:(%v) ==> (%v)", em.BaseInfo.Name, matches[1]) - em.ForeignKeyList = append(em.ForeignKeyList, model.ForeignKey{ - TableName: tmp[0], - ColumnName: tmp[1], - }) - } - - return true -} diff --git a/data/view/model/genmssql/def.go b/data/view/model/genmssql/def.go deleted file mode 100644 index f57c07e..0000000 --- a/data/view/model/genmssql/def.go +++ /dev/null @@ -1,46 +0,0 @@ -package genmssql - -import "regexp" - -// genColumns show full columns -type genColumns struct { - Field string `gorm:"column:Field"` - Type string `gorm:"column:Type"` - Key string `gorm:"column:Key"` - Desc string `gorm:"column:Comment"` - Null string `gorm:"column:Null"` - Default *string `gorm:"column:Default"` -} - -//select table_schema,table_name,column_name,referenced_table_schema,referenced_table_name,referenced_column_name from INFORMATION_SCHEMA.KEY_COLUMN_USAGE -// where table_schema ='matrix' AND REFERENCED_TABLE_NAME IS NOT NULL AND TABLE_NAME = 'credit_card' ; -// genForeignKey Foreign key of db info . 表的外键信息 -type genForeignKey struct { - TableSchema string `gorm:"column:table_schema"` // Database of columns.列所在的数据库 - TableName string `gorm:"column:table_name"` // Data table of column.列所在的数据表 - ColumnName string `gorm:"column:column_name"` // Column names.列名 - ReferencedTableSchema string `gorm:"column:referenced_table_schema"` // The database where the index is located.该索引所在的数据库 - ReferencedTableName string `gorm:"column:referenced_table_name"` // Affected tables . 该索引受影响的表 - ReferencedColumnName string `gorm:"column:referenced_column_name"` // Which column of the affected table.该索引受影响的表的哪一列 -} - -///////////////////////////////////////////////////////////////////////// - -// TableDescription 表及表注释 -type TableDescription struct { - Name string `gorm:"column:name"` // 表名 - Value string `gorm:"column:value"` // 表注释 -} - -type ColumnKeys struct { - ID int `gorm:"column:id"` - Name string `gorm:"column:name"` // 列名 - Pk int `gorm:"column:pk"` // 是否主键 - Type string `gorm:"column:tp"` // 类型 - Length int `gorm:"column:len"` // 长度 - Isnull int `gorm:"column:isnull"` // 是否为空 - Desc string `gorm:"column:des"` // 列注释 -} - -var noteRegex = regexp.MustCompile(`^\[@gorm\s(\S+)+\]`) -var foreignKeyRegex = regexp.MustCompile(`^\[@fk\s(\S+)+\]`) diff --git a/data/view/model/genmssql/genmssql.go b/data/view/model/genmssql/genmssql.go deleted file mode 100644 index ddad304..0000000 --- a/data/view/model/genmssql/genmssql.go +++ /dev/null @@ -1,257 +0,0 @@ -package genmssql - -import ( - "fmt" - "sort" - "strings" - - "github.com/xxjwxc/gormt/data/config" - "github.com/xxjwxc/gormt/data/view/model" - "github.com/xxjwxc/public/mylog" - "github.com/xxjwxc/public/tools" - "gorm.io/driver/sqlserver" - "gorm.io/gorm" -) - -// MssqlModel mysql model from IModel -var MssqlModel mssqlModel - -type mssqlModel struct { -} - -// GenModel get model.DBInfo info.获取数据库相关属性 -func (m *mssqlModel) GenModel() model.DBInfo { - dsn := fmt.Sprintf("server=%v;database=%v;user id=%v;password=%v;port=%v;encrypt=disable", - config.GetDbInfo().Host, config.GetDbInfo().Database, config.GetDbInfo().Username, config.GetDbInfo().Password, config.GetDbInfo().Port) - db, err := gorm.Open(sqlserver.Open(dsn), &gorm.Config{}) - if err != nil { - mylog.Error(err) - return model.DBInfo{} - } - defer func() { - sqldb, _ := db.DB() - sqldb.Close() - }() - - var dbInfo model.DBInfo - m.getPackageInfo(db, &dbInfo) - dbInfo.PackageName = m.GetPkgName() - dbInfo.DbName = m.GetDbName() - return dbInfo -} - -// GetDbName get database name.获取数据库名字 -func (m *mssqlModel) GetDbName() string { - return config.GetDbInfo().Database -} - -// GetTableNames get table name.获取格式化后指定的表名 -func (m *mssqlModel) GetTableNames() string { - return config.GetTableNames() -} - -// GetOriginTableNames get table name.获取原始指定的表名 -func (m *mssqlModel) GetOriginTableNames() string { - return config.GetOriginTableNames() -} - -// GetPkgName package names through config outdir configuration.通过config outdir 配置获取包名 -func (m *mssqlModel) GetPkgName() string { - dir := config.GetOutDir() - dir = strings.Replace(dir, "\\", "/", -1) - if len(dir) > 0 { - if dir[len(dir)-1] == '/' { - dir = dir[:(len(dir) - 1)] - } - } - var pkgName string - list := strings.Split(dir, "/") - if len(list) > 0 { - pkgName = list[len(list)-1] - } - - if len(pkgName) == 0 || pkgName == "." { - list = strings.Split(tools.GetModelPath(), "/") - if len(list) > 0 { - pkgName = list[len(list)-1] - } - } - - return pkgName -} - -func (m *mssqlModel) getPackageInfo(orm *gorm.DB, info *model.DBInfo) { - tabls := m.getTables(orm) // get table and notes - // if m := config.GetTableList(); len(m) > 0 { - // // 制定了表之后 - // newTabls := make(map[string]string) - // for t := range m { - // if notes, ok := tabls[t]; ok { - // newTabls[t] = notes - // } else { - // fmt.Printf("table: %s not found in db\n", t) - // } - // } - // tabls = newTabls - // } - for tabName, notes := range tabls { - var tab model.TabInfo - tab.Name = tabName - tab.Notes = notes - - if config.GetIsOutSQL() { - // TODO:获取创建sql语句 - // Get create SQL statements.获取创建sql语句 - // rows, err := orm.Raw("show create table " + assemblyTable(tabName)).Rows() - // //defer rows.Close() - // if err == nil { - // if rows.Next() { - // var table, CreateTable string - // rows.Scan(&table, &CreateTable) - // tab.SQLBuildStr = CreateTable - // } - // } - // rows.Close() - // ----------end - } - - // build element.构造元素 - tab.Em = m.getTableElement(orm, tabName) - // --------end - - info.TabList = append(info.TabList, tab) - } - // sort tables - sort.Slice(info.TabList, func(i, j int) bool { - return info.TabList[i].Name < info.TabList[j].Name - }) -} - -// getTableElement Get table columns and comments.获取表列及注释 -func (m *mssqlModel) getTableElement(orm *gorm.DB, tab string) (el []model.ColumnsInfo) { - sql := fmt.Sprintf(`SELECT - id = a.colorder, - name = a.name, - pk = case when exists(SELECT 1 FROM sysobjects where xtype='PK' and parent_obj=a.id and name in ( - SELECT name FROM sysindexes WHERE indid in( SELECT indid FROM sysindexkeys WHERE id = a.id AND colid=a.colid))) then 1 else 0 end, - tp = b.name, - len = COLUMNPROPERTY(a.id,a.name,'PRECISION'), - isnull = a.isnullable, - des = isnull(g.[value],'') -FROM - syscolumns a -left join - systypes b -on - a.xusertype=b.xusertype -inner join - sysobjects d -on - a.id=d.id and d.xtype='U' and d.name<>'dtproperties' -left join -sys.extended_properties g -on - a.id=G.major_id and a.colid=g.minor_id -left join -sys.extended_properties f -on - d.id=f.major_id and f.minor_id=0 -where - d.name='%v' -order by - a.colorder`, tab) - - lenPk := 0 - // get keys - var Keys []ColumnKeys - orm.Raw(sql).Scan(&Keys) - for i := 0; i < len(Keys); i++ { - v := &Keys[i] - if v.Pk == 1 { - lenPk++ - } - if strings.EqualFold(v.Type, "varchar") { // 字符串 - v.Type = fmt.Sprintf("varchar(%v)", v.Length) - } else if strings.EqualFold(v.Type, "int") { // int - v.Type = fmt.Sprintf("int(%v)", v.Length) - } - } - // ----------end - - // TODO:ForeignKey - - for _, v := range Keys { - var tmp model.ColumnsInfo - tmp.Name = v.Name - tmp.Type = v.Type - FixNotes(&tmp, v.Desc) // 分析表注释 - - if v.Pk > 0 { // 主键,或者联合组件 - if lenPk <= 1 { // 主键 - tmp.Index = append(tmp.Index, model.KList{ - Key: model.ColumnsKeyPrimary, - Multi: false, - KeyType: "primaryKey", - }) - } else { - tmp.Index = append(tmp.Index, model.KList{ - Key: model.ColumnsKeyPrimary, - Multi: true, - KeyType: "FULLTEXT", - }) - } - } - - tmp.IsNull = (v.Isnull == 1) - - el = append(el, tmp) - } - return -} - -// getTables Get columns and comments.获取表列及注释 -func (m *mssqlModel) getTables(orm *gorm.DB) map[string]string { - tbDesc := make(map[string]string) - - // Get column names.获取列名 - if m.GetOriginTableNames() != "" { - sarr := strings.Split(m.GetOriginTableNames(), ",") - if len(sarr) != 0 { - for _, val := range sarr { - tbDesc[val] = "" - } - } - } else { - var list []TableDescription - err := orm.Raw(`SELECT DISTINCT - d.name, - f.value - FROM - syscolumns a - LEFT JOIN systypes b ON a.xusertype= b.xusertype - INNER JOIN sysobjects d ON a.id= d.id - AND d.xtype= 'U' - AND d.name<> 'dtproperties' - LEFT JOIN syscomments e ON a.cdefault= e.id - LEFT JOIN sys.extended_properties g ON a.id= G.major_id - AND a.colid= g.minor_id - LEFT JOIN sys.extended_properties f ON d.id= f.major_id - AND f.minor_id= 0 ;`).Scan(&list).Error - if err != nil { - if !config.GetIsGUI() { - fmt.Println(err) - } - return tbDesc - } - - for _, v := range list { - tbDesc[v.Name] = v.Value - } - } - - return tbDesc -} - -func assemblyTable(name string) string { - return "`" + name + "`" -} diff --git a/data/view/model/genmysql/common.go b/data/view/model/genmysql/common.go old mode 100644 new mode 100755 diff --git a/data/view/model/genmysql/def.go b/data/view/model/genmysql/def.go old mode 100644 new mode 100755 diff --git a/data/view/model/genmysql/genmysql.go b/data/view/model/genmysql/genmysql.go old mode 100644 new mode 100755 diff --git a/data/view/model/gensqlite/common.go b/data/view/model/gensqlite/common.go deleted file mode 100644 index 7c6f962..0000000 --- a/data/view/model/gensqlite/common.go +++ /dev/null @@ -1,96 +0,0 @@ -package gensqlite - -import ( - "strings" - - "github.com/xxjwxc/gormt/data/config" - - "github.com/xxjwxc/gormt/data/view/model" -) - -// filterModel filter.过滤 gorm.Model -func filterModel(list *[]genColumns) bool { - if config.GetDBTag() != "gorm" || !config.GetUserGormModel() { - return false - } - - var _temp []genColumns - num := 0 - for _, v := range *list { - if strings.EqualFold(v.Name, "id") || - strings.EqualFold(v.Name, "created_at") || - strings.EqualFold(v.Name, "updated_at") || - strings.EqualFold(v.Name, "deleted_at") { - num++ - } else { - _temp = append(_temp, v) - } - } - - if num >= 4 { - *list = _temp - return true - } - - return false -} - -// fixForeignKey fix foreign key.过滤外键 -func fixForeignKey(list []genForeignKey, columuName string, result *[]model.ForeignKey) { - for _, v := range list { - if strings.EqualFold(v.ColumnName, columuName) { // find it .找到了 - *result = append(*result, model.ForeignKey{ - TableName: v.ReferencedTableName, - ColumnName: v.ReferencedColumnName, - }) - } - } -} - -// GetModel get model interface. 获取model接口 -func GetModel() model.IModel { - //now just support mysql - return &SQLiteModel -} - -// FixNotes 分析元素表注释 -func FixNotes(em *model.ColumnsInfo, note string) { - b0 := FixElementTag(em, note) // gorm - b1 := FixForeignKeyTag(em, em.Notes) // 外键 - if !b0 && b1 { // 补偿 - FixElementTag(em, em.Notes) // gorm - } -} - -// FixElementTag 分析元素表注释 -func FixElementTag(em *model.ColumnsInfo, note string) bool { - matches := noteRegex.FindStringSubmatch(note) - if len(matches) < 2 { - em.Notes = note - return false - } - em.Notes = note[len(matches[0]):] - em.Gormt = matches[1] - return true -} - -// FixForeignKeyTag 分析元素表注释(外键) -func FixForeignKeyTag(em *model.ColumnsInfo, note string) bool { - matches := foreignKeyRegex.FindStringSubmatch(note) // foreign key 外键 - if len(matches) < 2 { - em.Notes = note - return false - } - em.Notes = note[len(matches[0]):] - - // foreign key 外键 - tmp := strings.Split(matches[1], ".") - if len(tmp) > 0 { - em.ForeignKeyList = append(em.ForeignKeyList, model.ForeignKey{ - TableName: tmp[0], - ColumnName: tmp[1], - }) - } - - return true -} diff --git a/data/view/model/gensqlite/def.go b/data/view/model/gensqlite/def.go deleted file mode 100644 index cc74e86..0000000 --- a/data/view/model/gensqlite/def.go +++ /dev/null @@ -1,32 +0,0 @@ -package gensqlite - -import "regexp" - -type keys struct { - NonUnique int `gorm:"column:Non_unique"` - KeyName string `gorm:"column:Key_name"` - ColumnName string `gorm:"column:Column_name"` -} - -// genColumns show full columns -type genColumns struct { - Name string `gorm:"column:name"` - Type string `gorm:"column:type"` - Pk int `gorm:"column:pk"` - NotNull int `gorm:"column:notnull"` -} - -//select table_schema,table_name,column_name,referenced_table_schema,referenced_table_name,referenced_column_name from INFORMATION_SCHEMA.KEY_COLUMN_USAGE -// where table_schema ='matrix' AND REFERENCED_TABLE_NAME IS NOT NULL AND TABLE_NAME = 'credit_card' ; -// genForeignKey Foreign key of db info . 表的外键信息 -type genForeignKey struct { - TableSchema string `gorm:"column:table_schema"` // Database of columns.列所在的数据库 - TableName string `gorm:"column:table_name"` // Data table of column.列所在的数据表 - ColumnName string `gorm:"column:column_name"` // Column names.列名 - ReferencedTableSchema string `gorm:"column:referenced_table_schema"` // The database where the index is located.该索引所在的数据库 - ReferencedTableName string `gorm:"column:referenced_table_name"` // Affected tables . 该索引受影响的表 - ReferencedColumnName string `gorm:"column:referenced_column_name"` // Which column of the affected table.该索引受影响的表的哪一列 -} - -var noteRegex = regexp.MustCompile(`^\[@gorm\s(\S+)+\]`) -var foreignKeyRegex = regexp.MustCompile(`^\[@fk\s(\S+)+\]`) diff --git a/data/view/model/gensqlite/gensqlite.go b/data/view/model/gensqlite/gensqlite.go deleted file mode 100644 index 736d8c3..0000000 --- a/data/view/model/gensqlite/gensqlite.go +++ /dev/null @@ -1,205 +0,0 @@ -package gensqlite - -import ( - "fmt" - "sort" - "strings" - - "github.com/xxjwxc/public/mylog" - - "github.com/xxjwxc/gormt/data/config" - "github.com/xxjwxc/gormt/data/view/model" - "github.com/xxjwxc/public/tools" - "gorm.io/driver/sqlite" - "gorm.io/gorm" -) - -// SQLiteModel mysql model from IModel -var SQLiteModel sqliteModel - -type sqliteModel struct { -} - -// GenModel get model.DBInfo info.获取数据库相关属性 -func (m *sqliteModel) GenModel() model.DBInfo { - db, err := gorm.Open(sqlite.Open(config.GetDbInfo().Host), &gorm.Config{}) - if err != nil { - mylog.Error(err) - return model.DBInfo{} - } - defer func() { - sqldb, _ := db.DB() - sqldb.Close() - }() - - var dbInfo model.DBInfo - m.getPackageInfo(db, &dbInfo) - dbInfo.PackageName = m.GetPkgName() - dbInfo.DbName = m.GetDbName() - return dbInfo -} - -// GetDbName get database name.获取数据库名字 -func (m *sqliteModel) GetDbName() string { - dir := config.GetDbInfo().Host - dir = strings.Replace(dir, "\\", "/", -1) - if len(dir) > 0 { - if dir[len(dir)-1] == '/' { - dir = dir[:(len(dir) - 1)] - } - } - var dbName string - list := strings.Split(dir, "/") - if len(list) > 0 { - dbName = list[len(list)-1] - } - list = strings.Split(dbName, ".") - if len(list) > 0 { - dbName = list[0] - } - - if len(dbName) == 0 || dbName == "." { - panic(fmt.Sprintf("%v : db host config err.must file dir", dbName)) - } - - return dbName -} - -// GetTableNames get table name.获取指定的表名 -func (m *sqliteModel) GetTableNames() string { - return config.GetTableNames() -} - -// GetPkgName package names through config outdir configuration.通过config outdir 配置获取包名 -func (m *sqliteModel) GetPkgName() string { - dir := config.GetOutDir() - dir = strings.Replace(dir, "\\", "/", -1) - if len(dir) > 0 { - if dir[len(dir)-1] == '/' { - dir = dir[:(len(dir) - 1)] - } - } - var pkgName string - list := strings.Split(dir, "/") - if len(list) > 0 { - pkgName = list[len(list)-1] - } - - if len(pkgName) == 0 || pkgName == "." { - list = strings.Split(tools.GetModelPath(), "/") - if len(list) > 0 { - pkgName = list[len(list)-1] - } - } - - return pkgName -} - -func (m *sqliteModel) getPackageInfo(orm *gorm.DB, info *model.DBInfo) { - tabls := m.getTables(orm) // get table and notes - for tabName, notes := range tabls { - var tab model.TabInfo - tab.Name = tabName - tab.Notes = notes - - if config.GetIsOutSQL() { - // Get create SQL statements.获取创建sql语句 - rows, err := orm.Raw("SELECT tbl_name,sql FROM sqlite_master WHERE type='table' AND name = " + assemblyTable(tabName)).Rows() - //defer rows.Close() - if err == nil { - if rows.Next() { - var table, CreateTable string - rows.Scan(&table, &CreateTable) - tab.SQLBuildStr = CreateTable - } - } - rows.Close() - // ----------end - } - - // build element.构造元素 - tab.Em = m.getTableElement(orm, tabName) - // --------end - - info.TabList = append(info.TabList, tab) - } - // sort tables - sort.Slice(info.TabList, func(i, j int) bool { - return info.TabList[i].Name < info.TabList[j].Name - }) -} - -// getTableElement Get table columns and comments.获取表列及注释 -func (m *sqliteModel) getTableElement(orm *gorm.DB, tab string) (el []model.ColumnsInfo) { - var list []genColumns - // Get table annotations.获取表注释 - orm.Raw(fmt.Sprintf("PRAGMA table_info(%v)", assemblyTable(tab))).Scan(&list) - // filter gorm.Model.过滤 gorm.Model - if filterModel(&list) { - el = append(el, model.ColumnsInfo{ - Type: "gorm.Model", - }) - } - // -----------------end - - // ForeignKey - var foreignKeyList []genForeignKey - if config.GetIsForeignKey() { - } - // ------------------end - - for _, v := range list { - var tmp model.ColumnsInfo - tmp.Name = v.Name - tmp.Type = v.Type - FixNotes(&tmp, "") - if v.Pk == 1 { // 主键 - tmp.Index = append(tmp.Index, model.KList{ - Key: model.ColumnsKeyPrimary, - Multi: false, - }) - } - - tmp.IsNull = (v.NotNull != 1) - - // ForeignKey - fixForeignKey(foreignKeyList, tmp.Name, &tmp.ForeignKeyList) - // -----------------end - el = append(el, tmp) - } - return -} - -// getTables Get columns and comments.获取表列及注释 -func (m *sqliteModel) getTables(orm *gorm.DB) map[string]string { - tbDesc := make(map[string]string) - - // Get column names.获取列名 - var tables []string - - rows, err := orm.Raw("SELECT name FROM sqlite_master WHERE type='table'").Rows() - if err != nil { - if !config.GetIsGUI() { - fmt.Println(err) - } - return tbDesc - } - - for rows.Next() { - var table string - rows.Scan(&table) - if !strings.EqualFold(table, "sqlite_sequence") { // 剔除系统默认 - tables = append(tables, table) - tbDesc[table] = "" - } - } - rows.Close() - - // TODO.获取表注释 - - return tbDesc -} - -func assemblyTable(name string) string { - return "'" + name + "'" -} diff --git a/data/view/model/model_test.go b/data/view/model/model_test.go old mode 100644 new mode 100755 index 91891ab..59497d7 --- a/data/view/model/model_test.go +++ b/data/view/model/model_test.go @@ -12,7 +12,7 @@ func TestTypeName(t *testing.T) { } func TestTools(t *testing.T) { - str := `{"DbName":"oauth_db","PackageName":"model","TabList":[{"Name":"user_account_tbl","Notes":"用户账号","SQLBuildStr":"","Em":[{"Name":"id","Notes":"","Type":"int(11)","Index":[{"Key":1,"KeyName":""}],"IsNull":false,"ForeignKeyList":null},{"Name":"account","Notes":"","Type":"varchar(64)","Index":[{"Key":2,"KeyName":""}],"IsNull":false,"ForeignKeyList":null},{"Name":"password","Notes":"","Type":"varchar(64)","Index":null,"IsNull":false,"ForeignKeyList":null},{"Name":"account_type","Notes":"帐号类型:0手机号,1邮件","Type":"int(11)","Index":null,"IsNull":false,"ForeignKeyList":null},{"Name":"app_key","Notes":"authbucket_oauth2_client表的id","Type":"varchar(255)","Index":null,"IsNull":false,"ForeignKeyList":null},{"Name":"user_info_tbl_id","Notes":"","Type":"int(11)","Index":[{"Key":3,"KeyName":"user_info_id"}],"IsNull":false,"ForeignKeyList":[{"TableName":"user_info_tbl","ColumnName":"id"}]},{"Name":"reg_time","Notes":"","Type":"datetime","Index":null,"IsNull":true,"ForeignKeyList":null},{"Name":"reg_ip","Notes":"","Type":"varchar(15)","Index":[{"Key":3,"KeyName":"user_info_id"}],"IsNull":true,"ForeignKeyList":null},{"Name":"bundle_id","Notes":"","Type":"varchar(255)","Index":null,"IsNull":true,"ForeignKeyList":null},{"Name":"describ","Notes":"","Type":"varchar(255)","Index":null,"IsNull":true,"ForeignKeyList":null}]},{"Name":"user_info_tbl","Notes":"用户信息","SQLBuildStr":"","Em":[{"Name":"","Notes":"","Type":"gorm.Model","Index":null,"IsNull":false,"ForeignKeyList":null},{"Name":"nickname","Notes":"","Type":"varchar(32)","Index":null,"IsNull":false,"ForeignKeyList":null},{"Name":"headurl","Notes":"","Type":"varchar(255)","Index":null,"IsNull":true,"ForeignKeyList":null}]},{"Name":"oauth2_access_token","Notes":"token认证","SQLBuildStr":"","Em":[{"Name":"id","Notes":"","Type":"int(11)","Index":[{"Key":1,"KeyName":""}],"IsNull":false,"ForeignKeyList":null},{"Name":"access_token","Notes":"","Type":"varchar(255)","Index":[{"Key":2,"KeyName":""}],"IsNull":false,"ForeignKeyList":null},{"Name":"token_type","Notes":"","Type":"varchar(255)","Index":null,"IsNull":false,"ForeignKeyList":null},{"Name":"app_key","Notes":"key","Type":"varchar(255)","Index":null,"IsNull":false,"ForeignKeyList":null},{"Name":"username","Notes":"用户名","Type":"varchar(255)","Index":null,"IsNull":false,"ForeignKeyList":null},{"Name":"expires","Notes":"过期时间","Type":"datetime","Index":null,"IsNull":false,"ForeignKeyList":null}]},{"Name":"user","Notes":"","SQLBuildStr":"","Em":[{"Name":"userId","Notes":"","Type":"int(11)","Index":[{"Key":1,"KeyName":""}],"IsNull":false,"ForeignKeyList":null},{"Name":"name","Notes":"","Type":"varchar(30)","Index":null,"IsNull":false,"ForeignKeyList":null},{"Name":"sex","Notes":"","Type":"int(11)","Index":[{"Key":3,"KeyName":""}],"IsNull":false,"ForeignKeyList":null},{"Name":"job","Notes":"","Type":"int(11)","Index":null,"IsNull":false,"ForeignKeyList":null}]},{"Name":"organ","Notes":"","SQLBuildStr":"","Em":[{"Name":"id","Notes":"","Type":"int(11)","Index":[{"Key":1,"KeyName":""}],"IsNull":false,"ForeignKeyList":null},{"Name":"userId","Notes":"","Type":"int(11)","Index":[{"Key":3,"KeyName":""}],"IsNull":true,"ForeignKeyList":[{"TableName":"user","ColumnName":"sex"}]},{"Name":"type","Notes":"","Type":"int(11)","Index":null,"IsNull":true,"ForeignKeyList":null},{"Name":"score","Notes":"","Type":"int(11)","Index":null,"IsNull":true,"ForeignKeyList":null}]},{"Name":"sign_client_tbl","Notes":"","SQLBuildStr":"","Em":[{"Name":"id","Notes":"","Type":"int(11)","Index":[{"Key":1,"KeyName":""}],"IsNull":false,"ForeignKeyList":null},{"Name":"app_key","Notes":"","Type":"varchar(255)","Index":null,"IsNull":false,"ForeignKeyList":null},{"Name":"app_secret","Notes":"","Type":"varchar(255)","Index":null,"IsNull":false,"ForeignKeyList":null},{"Name":"expire_time","Notes":"超时时间","Type":"datetime","Index":null,"IsNull":false,"ForeignKeyList":null},{"Name":"strict_sign","Notes":"是否强制验签:0:用户自定义,1:强制","Type":"int(255)","Index":null,"IsNull":true,"ForeignKeyList":null},{"Name":"strict_verify","Notes":"是否强制验证码:0:用户自定义,1:强制","Type":"int(11)","Index":null,"IsNull":false,"ForeignKeyList":null},{"Name":"token_expire_time","Notes":"token过期时间","Type":"int(11)","Index":null,"IsNull":false,"ForeignKeyList":null}]},{"Name":"user_paybill_order","Notes":"","SQLBuildStr":"","Em":[{"Name":"id","Notes":"","Type":"int(11)","Index":[{"Key":1,"KeyName":""}],"IsNull":false,"ForeignKeyList":null},{"Name":"paybill_id","Notes":"二次账单id","Type":"bigint(20)","Index":[{"Key":3,"KeyName":"order_id"}],"IsNull":false,"ForeignKeyList":null},{"Name":"order_id_mysql","Notes":"MySql中的订单Id","Type":"bigint(20)","Index":[{"Key":3,"KeyName":"order_id"}],"IsNull":false,"ForeignKeyList":null},{"Name":"order_item_id_mysql","Notes":"MySql中的订单ItemId","Type":"bigint(20)","Index":[{"Key":3,"KeyName":"order_id"}],"IsNull":false,"ForeignKeyList":null},{"Name":"order_id_mssql","Notes":"MsSql中的订单Id","Type":"bigint(20)","Index":null,"IsNull":false,"ForeignKeyList":null}]},{"Name":"oauth2_client_tbl","Notes":"client key 信息","SQLBuildStr":"","Em":[{"Name":"id","Notes":"","Type":"int(11)","Index":[{"Key":1,"KeyName":""}],"IsNull":false,"ForeignKeyList":null},{"Name":"app_key","Notes":"","Type":"varchar(255)","Index":null,"IsNull":false,"ForeignKeyList":null},{"Name":"app_secret","Notes":"","Type":"varchar(255)","Index":null,"IsNull":false,"ForeignKeyList":null},{"Name":"expire_time","Notes":"超时时间","Type":"datetime","Index":null,"IsNull":false,"ForeignKeyList":null},{"Name":"strict_sign","Notes":"是否强制验签:0:用户自定义,1:强制","Type":"int(255)","Index":null,"IsNull":true,"ForeignKeyList":null},{"Name":"strict_verify","Notes":"是否强制验证码:0:用户自定义,1:强制","Type":"int(11)","Index":null,"IsNull":false,"ForeignKeyList":null},{"Name":"token_expire_time","Notes":"token过期时间","Type":"int(11)","Index":null,"IsNull":false,"ForeignKeyList":null},{"Name":"aaa","Notes":"","Type":"json","Index":null,"IsNull":true,"ForeignKeyList":null}]},{"Name":"oauth2_refresh_token","Notes":"刷新token","SQLBuildStr":"","Em":[{"Name":"id","Notes":"","Type":"int(11)","Index":[{"Key":1,"KeyName":""}],"IsNull":false,"ForeignKeyList":null},{"Name":"refresh_token","Notes":"","Type":"varchar(255)","Index":[{"Key":2,"KeyName":""}],"IsNull":false,"ForeignKeyList":null},{"Name":"token_type","Notes":"","Type":"varchar(255)","Index":null,"IsNull":false,"ForeignKeyList":null},{"Name":"app_key","Notes":"","Type":"varchar(255)","Index":null,"IsNull":false,"ForeignKeyList":null},{"Name":"username","Notes":"","Type":"varchar(255)","Index":null,"IsNull":false,"ForeignKeyList":null},{"Name":"expires","Notes":"","Type":"datetime","Index":null,"IsNull":false,"ForeignKeyList":null},{"Name":"token_expire_time","Notes":"","Type":"int(11)","Index":null,"IsNull":false,"ForeignKeyList":null}]}]}` + str := `{"DbName":"oauth_db","PackageName":"model","TabList":[{"ChainType":"user_account_tbl","Notes":"用户账号","SQLBuildStr":"","Em":[{"ChainType":"id","Notes":"","Type":"int(11)","Index":[{"Key":1,"KeyName":""}],"IsNull":false,"ForeignKeyList":null},{"ChainType":"account","Notes":"","Type":"varchar(64)","Index":[{"Key":2,"KeyName":""}],"IsNull":false,"ForeignKeyList":null},{"ChainType":"password","Notes":"","Type":"varchar(64)","Index":null,"IsNull":false,"ForeignKeyList":null},{"ChainType":"account_type","Notes":"帐号类型:0手机号,1邮件","Type":"int(11)","Index":null,"IsNull":false,"ForeignKeyList":null},{"ChainType":"app_key","Notes":"authbucket_oauth2_client表的id","Type":"varchar(255)","Index":null,"IsNull":false,"ForeignKeyList":null},{"ChainType":"user_info_tbl_id","Notes":"","Type":"int(11)","Index":[{"Key":3,"KeyName":"user_info_id"}],"IsNull":false,"ForeignKeyList":[{"TableName":"user_info_tbl","ColumnName":"id"}]},{"ChainType":"reg_time","Notes":"","Type":"datetime","Index":null,"IsNull":true,"ForeignKeyList":null},{"ChainType":"reg_ip","Notes":"","Type":"varchar(15)","Index":[{"Key":3,"KeyName":"user_info_id"}],"IsNull":true,"ForeignKeyList":null},{"ChainType":"bundle_id","Notes":"","Type":"varchar(255)","Index":null,"IsNull":true,"ForeignKeyList":null},{"ChainType":"describ","Notes":"","Type":"varchar(255)","Index":null,"IsNull":true,"ForeignKeyList":null}]},{"ChainType":"user_info_tbl","Notes":"用户信息","SQLBuildStr":"","Em":[{"ChainType":"","Notes":"","Type":"gorm.Model","Index":null,"IsNull":false,"ForeignKeyList":null},{"ChainType":"nickname","Notes":"","Type":"varchar(32)","Index":null,"IsNull":false,"ForeignKeyList":null},{"ChainType":"headurl","Notes":"","Type":"varchar(255)","Index":null,"IsNull":true,"ForeignKeyList":null}]},{"ChainType":"oauth2_access_token","Notes":"token认证","SQLBuildStr":"","Em":[{"ChainType":"id","Notes":"","Type":"int(11)","Index":[{"Key":1,"KeyName":""}],"IsNull":false,"ForeignKeyList":null},{"ChainType":"access_token","Notes":"","Type":"varchar(255)","Index":[{"Key":2,"KeyName":""}],"IsNull":false,"ForeignKeyList":null},{"ChainType":"token_type","Notes":"","Type":"varchar(255)","Index":null,"IsNull":false,"ForeignKeyList":null},{"ChainType":"app_key","Notes":"key","Type":"varchar(255)","Index":null,"IsNull":false,"ForeignKeyList":null},{"ChainType":"username","Notes":"用户名","Type":"varchar(255)","Index":null,"IsNull":false,"ForeignKeyList":null},{"ChainType":"expires","Notes":"过期时间","Type":"datetime","Index":null,"IsNull":false,"ForeignKeyList":null}]},{"ChainType":"user","Notes":"","SQLBuildStr":"","Em":[{"ChainType":"userId","Notes":"","Type":"int(11)","Index":[{"Key":1,"KeyName":""}],"IsNull":false,"ForeignKeyList":null},{"ChainType":"name","Notes":"","Type":"varchar(30)","Index":null,"IsNull":false,"ForeignKeyList":null},{"ChainType":"sex","Notes":"","Type":"int(11)","Index":[{"Key":3,"KeyName":""}],"IsNull":false,"ForeignKeyList":null},{"ChainType":"job","Notes":"","Type":"int(11)","Index":null,"IsNull":false,"ForeignKeyList":null}]},{"ChainType":"organ","Notes":"","SQLBuildStr":"","Em":[{"ChainType":"id","Notes":"","Type":"int(11)","Index":[{"Key":1,"KeyName":""}],"IsNull":false,"ForeignKeyList":null},{"ChainType":"userId","Notes":"","Type":"int(11)","Index":[{"Key":3,"KeyName":""}],"IsNull":true,"ForeignKeyList":[{"TableName":"user","ColumnName":"sex"}]},{"ChainType":"type","Notes":"","Type":"int(11)","Index":null,"IsNull":true,"ForeignKeyList":null},{"ChainType":"score","Notes":"","Type":"int(11)","Index":null,"IsNull":true,"ForeignKeyList":null}]},{"ChainType":"sign_client_tbl","Notes":"","SQLBuildStr":"","Em":[{"ChainType":"id","Notes":"","Type":"int(11)","Index":[{"Key":1,"KeyName":""}],"IsNull":false,"ForeignKeyList":null},{"ChainType":"app_key","Notes":"","Type":"varchar(255)","Index":null,"IsNull":false,"ForeignKeyList":null},{"ChainType":"app_secret","Notes":"","Type":"varchar(255)","Index":null,"IsNull":false,"ForeignKeyList":null},{"ChainType":"expire_time","Notes":"超时时间","Type":"datetime","Index":null,"IsNull":false,"ForeignKeyList":null},{"ChainType":"strict_sign","Notes":"是否强制验签:0:用户自定义,1:强制","Type":"int(255)","Index":null,"IsNull":true,"ForeignKeyList":null},{"ChainType":"strict_verify","Notes":"是否强制验证码:0:用户自定义,1:强制","Type":"int(11)","Index":null,"IsNull":false,"ForeignKeyList":null},{"ChainType":"token_expire_time","Notes":"token过期时间","Type":"int(11)","Index":null,"IsNull":false,"ForeignKeyList":null}]},{"ChainType":"user_paybill_order","Notes":"","SQLBuildStr":"","Em":[{"ChainType":"id","Notes":"","Type":"int(11)","Index":[{"Key":1,"KeyName":""}],"IsNull":false,"ForeignKeyList":null},{"ChainType":"paybill_id","Notes":"二次账单id","Type":"bigint(20)","Index":[{"Key":3,"KeyName":"order_id"}],"IsNull":false,"ForeignKeyList":null},{"ChainType":"order_id_mysql","Notes":"MySql中的订单Id","Type":"bigint(20)","Index":[{"Key":3,"KeyName":"order_id"}],"IsNull":false,"ForeignKeyList":null},{"ChainType":"order_item_id_mysql","Notes":"MySql中的订单ItemId","Type":"bigint(20)","Index":[{"Key":3,"KeyName":"order_id"}],"IsNull":false,"ForeignKeyList":null},{"ChainType":"order_id_mssql","Notes":"MsSql中的订单Id","Type":"bigint(20)","Index":null,"IsNull":false,"ForeignKeyList":null}]},{"ChainType":"oauth2_client_tbl","Notes":"client key 信息","SQLBuildStr":"","Em":[{"ChainType":"id","Notes":"","Type":"int(11)","Index":[{"Key":1,"KeyName":""}],"IsNull":false,"ForeignKeyList":null},{"ChainType":"app_key","Notes":"","Type":"varchar(255)","Index":null,"IsNull":false,"ForeignKeyList":null},{"ChainType":"app_secret","Notes":"","Type":"varchar(255)","Index":null,"IsNull":false,"ForeignKeyList":null},{"ChainType":"expire_time","Notes":"超时时间","Type":"datetime","Index":null,"IsNull":false,"ForeignKeyList":null},{"ChainType":"strict_sign","Notes":"是否强制验签:0:用户自定义,1:强制","Type":"int(255)","Index":null,"IsNull":true,"ForeignKeyList":null},{"ChainType":"strict_verify","Notes":"是否强制验证码:0:用户自定义,1:强制","Type":"int(11)","Index":null,"IsNull":false,"ForeignKeyList":null},{"ChainType":"token_expire_time","Notes":"token过期时间","Type":"int(11)","Index":null,"IsNull":false,"ForeignKeyList":null},{"ChainType":"aaa","Notes":"","Type":"json","Index":null,"IsNull":true,"ForeignKeyList":null}]},{"ChainType":"oauth2_refresh_token","Notes":"刷新token","SQLBuildStr":"","Em":[{"ChainType":"id","Notes":"","Type":"int(11)","Index":[{"Key":1,"KeyName":""}],"IsNull":false,"ForeignKeyList":null},{"ChainType":"refresh_token","Notes":"","Type":"varchar(255)","Index":[{"Key":2,"KeyName":""}],"IsNull":false,"ForeignKeyList":null},{"ChainType":"token_type","Notes":"","Type":"varchar(255)","Index":null,"IsNull":false,"ForeignKeyList":null},{"ChainType":"app_key","Notes":"","Type":"varchar(255)","Index":null,"IsNull":false,"ForeignKeyList":null},{"ChainType":"username","Notes":"","Type":"varchar(255)","Index":null,"IsNull":false,"ForeignKeyList":null},{"ChainType":"expires","Notes":"","Type":"datetime","Index":null,"IsNull":false,"ForeignKeyList":null},{"ChainType":"token_expire_time","Notes":"","Type":"int(11)","Index":null,"IsNull":false,"ForeignKeyList":null}]}]}` var pkg DBInfo json.Unmarshal([]byte(str), &pkg) // out, _ := json.Marshal(pkg) diff --git a/doc/export.md b/doc/export.md old mode 100644 new mode 100755 diff --git a/doc/export_cn.md b/doc/export_cn.md old mode 100644 new mode 100755 diff --git a/doc/func.md b/doc/func.md old mode 100644 new mode 100755 diff --git a/doc/func_cn.md b/doc/func_cn.md old mode 100644 new mode 100755 diff --git a/go.mod b/go.mod old mode 100644 new mode 100755 index e435ce4..abcd832 --- a/go.mod +++ b/go.mod @@ -14,9 +14,7 @@ require ( gopkg.in/go-playground/validator.v9 v9.30.2 gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c gorm.io/driver/mysql v1.0.1 - gorm.io/driver/sqlite v1.1.4 - gorm.io/driver/sqlserver v1.0.7 - gorm.io/gorm v1.21.4 + gorm.io/gorm v1.25.2-0.20230530020048-26663ab9bf55 ) // replace github.com/xxjwxc/public => ../public diff --git a/go.sum b/go.sum old mode 100644 new mode 100755 index 0810831..5e6bf47 --- a/go.sum +++ b/go.sum @@ -31,8 +31,6 @@ github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/denisenkom/go-mssqldb v0.0.0-20191124224453-732737034ffd/go.mod h1:xbL0rPBG9cCiLr28tMa8zpbdarY27NDyej4t/EjAShU= -github.com/denisenkom/go-mssqldb v0.9.0 h1:RSohk2RsiZqLZ0zCjtfn3S4Gp4exhpBWHyQ7D0yGjAk= -github.com/denisenkom/go-mssqldb v0.9.0/go.mod h1:xbL0rPBG9cCiLr28tMa8zpbdarY27NDyej4t/EjAShU= github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc= github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no= @@ -58,7 +56,6 @@ github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LB github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4= -github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe h1:lXe2qZdvpiX5WZkZR4hgp4KJVfY3nMkvmwbVkpv1rVY= github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe/go.mod h1:8vg3r2VgvsThLBIFL93Qb5yWzgyZWhEmBwUJWevAkK0= github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0/go.mod h1:E/TSTwGwJL78qG/PmXZO1EjYhfJinVAhrmmHX6Z8B9k= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= @@ -99,8 +96,8 @@ github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc= github.com/jinzhu/now v1.0.1/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8= github.com/jinzhu/now v1.1.1/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8= -github.com/jinzhu/now v1.1.2 h1:eVKgfIdy9b6zbWBMgFpfDPoAMifwSZagU9HmEU6zgiI= -github.com/jinzhu/now v1.1.2/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8= +github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ= +github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8= github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo= github.com/jroimartin/gocui v0.4.0 h1:52jnalstgmc25FmtGcWqa0tcbMEWS6RpFLsOIO+I+E8= github.com/jroimartin/gocui v0.4.0/go.mod h1:7i7bbj99OgFHzo7kB2zPb8pXLqMBSQegY7azfqXMkyY= @@ -123,8 +120,6 @@ github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czP github.com/mailru/easyjson v0.7.1/go.mod h1:KAzv3t3aY1NaHWoQz1+4F1ccyAH66Jk7yos7ldAVICs= github.com/mattn/go-runewidth v0.0.9 h1:Lm995f3rfxdpd6TSmuVCHVb/QhupuXlYr8sCI/QdE+0= github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= -github.com/mattn/go-sqlite3 v1.14.5/go.mod h1:WVKg1VTActs4Qso6iwGbiFih2UIHo0ENGwNd0Lj+XmI= -github.com/mattn/go-sqlite3 v2.0.1+incompatible h1:xQ15muvnzGBHpIpdrNi1DA5x0+TcBZzsIDwmw9uTHzw= github.com/mattn/go-sqlite3 v2.0.1+incompatible/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= @@ -208,8 +203,6 @@ golang.org/x/crypto v0.0.0-20190325154230-a5d413f7728c/go.mod h1:djNgcEr1/C05ACk golang.org/x/crypto v0.0.0-20190506204251-e1dfcc566284/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20191205180655-e7c4368fe9dd/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2 h1:It14KIkyBFYkHkwZ7k45minvA9aorojkyjGk9KJ5B/w= -golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/image v0.0.0-20200430140353-33d19683fad8/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= @@ -228,7 +221,6 @@ golang.org/x/net v0.0.0-20190522155817-f3200d17e092/go.mod h1:HSz+uSET+XFnRR8LxR golang.org/x/net v0.0.0-20200506145744-7e3656a0809f/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/net v0.0.0-20201202161906-c7110b5ffcbb/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -249,8 +241,6 @@ golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200519105757-fe76b779f299/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3 h1:cokOdA+Jmi5PJGXLlLllQSgYigAEfHXJAERHVMaCc2k= @@ -305,14 +295,9 @@ gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gorm.io/driver/mysql v1.0.1 h1:omJoilUzyrAp0xNoio88lGJCroGdIOen9hq2A/+3ifw= gorm.io/driver/mysql v1.0.1/go.mod h1:KtqSthtg55lFp3S5kUXqlGaelnWpKitn4k1xZTnoiPw= -gorm.io/driver/sqlite v1.1.4 h1:PDzwYE+sI6De2+mxAneV9Xs11+ZyKV6oxD3wDGkaNvM= -gorm.io/driver/sqlite v1.1.4/go.mod h1:mJCeTFr7+crvS+TRnWc5Z3UvwxUN1BGBLMrf5LA9DYw= -gorm.io/driver/sqlserver v1.0.7 h1:uwUtb0kdFwW5PkRbd2KJ2h4wlsqvLSjox1XVg/RnzRE= -gorm.io/driver/sqlserver v1.0.7/go.mod h1:ng66aHI47ZIKz/vvnxzDoonzmTS8HXP+JYlgg67wOog= gorm.io/gorm v1.9.19/go.mod h1:0HFTzE/SqkGTzK6TlDPPQbAYCluiVvhzoA1+aVyzenw= gorm.io/gorm v1.20.2/go.mod h1:0HFTzE/SqkGTzK6TlDPPQbAYCluiVvhzoA1+aVyzenw= -gorm.io/gorm v1.20.7/go.mod h1:0HFTzE/SqkGTzK6TlDPPQbAYCluiVvhzoA1+aVyzenw= -gorm.io/gorm v1.21.4 h1:J0xfPJMRfHgpVcYLrEAIqY/apdvTIkrltPQNHQLq9Qc= -gorm.io/gorm v1.21.4/go.mod h1:0HFTzE/SqkGTzK6TlDPPQbAYCluiVvhzoA1+aVyzenw= +gorm.io/gorm v1.25.2-0.20230530020048-26663ab9bf55 h1:sC1Xj4TYrLqg1n3AN10w871An7wJM0gzgcm8jkIkECQ= +gorm.io/gorm v1.25.2-0.20230530020048-26663ab9bf55/go.mod h1:L4uxeKpfBml98NYqVqwAdmV1a2nBtAec/cf3fpucW/k= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= diff --git a/gogenerate.go b/gogenerate.go old mode 100644 new mode 100755 diff --git a/image/.DS_Store b/image/.DS_Store old mode 100644 new mode 100755 index d0b340a0a63c43d04ef20397e9bb985d390d9011..cdd8ddbd99cbc4572f5bfcd8bf1f8279d9e273bb GIT binary patch delta 229 zcmZp1XmOa}&&aVcU^hP_$7CLXPyFeI!O8i#1q>iy;>@`Dy?`WZNN&E1OHxjL5>Sl8 z?Rt+dZ_p7(Ae)sTogts0h#{AuBsV{WfQo_)WRnXRHvbasW!%gz@r`BkeGyGYTG`RX F2mlFsJ)!^r delta 49 zcmZp1XmOa}&&aYdU^hP_%VZvbPn%@~xmY)Mh}APrY-rfbF7b_Jv$QBTBUGdo0FaXq ANdN!< diff --git a/image/gormt/1.png b/image/gormt/1.png old mode 100644 new mode 100755 diff --git a/image/gormt/2.jpg b/image/gormt/2.jpg old mode 100644 new mode 100755 diff --git a/image/gormt/3.jpg b/image/gormt/3.jpg old mode 100644 new mode 100755 diff --git a/image/gormt/4.jpg b/image/gormt/4.jpg old mode 100644 new mode 100755 diff --git a/image/gormt/out.gif b/image/gormt/out.gif old mode 100644 new mode 100755 diff --git a/image/gormt/ui_cn.gif b/image/gormt/ui_cn.gif old mode 100644 new mode 100755 diff --git a/image/gormt/ui_en.gif b/image/gormt/ui_en.gif old mode 100644 new mode 100755 diff --git a/jc_payment_withdraw.go b/jc_payment_withdraw.go new file mode 100755 index 0000000..3d4959a --- /dev/null +++ b/jc_payment_withdraw.go @@ -0,0 +1,311 @@ +package gormt + +import ( + "time" +) + +// JcPaymentWithdraw 用户提币订单表 +type JcPaymentWithdraw struct { + ID uint64 `gorm:"autoIncrement:true;primaryKey;column:id;type:bigint unsigned;not null;comment:'主键ID'" json:"id"` // 主键ID + InvoiceCode string `gorm:"unique;column:invoice_code;type:varchar(64);not null;default:'';comment:'发票编码'" json:"invoice_code"` // 发票编码 + AppID string `gorm:"column:app_id;type:varchar(64);not null;default:'';comment:'应用ID'" json:"app_id"` // 应用ID + OrderID string `gorm:"column:order_id;type:varchar(64);not null;default:'';comment:'游戏端订单ID'" json:"order_id"` // 游戏端订单ID + UserID string `gorm:"index:user_id;column:user_id;type:varchar(64);not null;default:'';comment:'用户游戏ID'" json:"user_id"` // 用户游戏ID + UserType int8 `gorm:"column:user_type;type:tinyint;not null;default:0;comment:'用户类型,0-玩家,1-商家,2-其他'" json:"user_type"` // 用户类型,0-玩家,1-商家,2-其他 + FromAddress string `gorm:"column:from_address;type:varchar(64);not null;default:'';comment:'发币账号地址'" json:"from_address"` // 发币账号地址 + ToAddress string `gorm:"column:to_address;type:varchar(64);not null;default:'';comment:'用户提币地址'" json:"to_address"` // 用户提币地址 + ChainNet string `gorm:"index:chain_net;column:chain_net;type:varchar(16);not null;default:'';comment:'网络类型, options:BTC|ERC20|BEP20|TRC20'" json:"chain_net"` // 网络类型, options:BTC|ERC20|BEP20|TRC20 + Token string `gorm:"index:token;column:token;type:varchar(16);not null;default:'';comment:'代币, options:BTC|USDT|ETH|BNB|TRX|USDP|USDC'" json:"token"` // 代币, options:BTC|USDT|ETH|BNB|TRX|USDP|USDC + AmountInput float64 `gorm:"column:amount_input;type:decimal(40,18);not null;default:0.000000000000000000;comment:'用户输入的提币金额'" json:"amount_input"` // 用户输入的提币金额 + AmountCredited float64 `gorm:"column:amount_credited;type:decimal(40,18);not null;default:0.000000000000000000;comment:'实际到账金额'" json:"amount_credited"` // 实际到账金额 + GasToken float64 `gorm:"column:gas_token;type:decimal(40,18);not null;default:0.000000000000000000;comment:'手续费换算对应token, 扣掉的, 基于gas_limit计算'" json:"gas_token"` // 手续费换算对应token, 扣掉的, 基于gas_limit计算 + GasRate float64 `gorm:"column:gas_rate;type:decimal(40,18);not null;default:0.000000000000000000;comment:'燃料费(基础币)兑token的汇率'" json:"gas_rate"` // 燃料费(基础币)兑token的汇率 + UserFeeRate float64 `gorm:"column:user_fee_rate;type:decimal(40,18);not null;default:0.000000000000000000;comment:'扣除玩家手续费的倍率,从配置文件中取'" json:"user_fee_rate"` // 扣除玩家手续费的倍率,从配置文件中取 + GasLimit float64 `gorm:"column:gas_limit;type:decimal(40,18);not null;default:0.000000000000000000;comment:'提币的燃料费限制'" json:"gas_limit"` // 提币的燃料费限制 + GasPrice float64 `gorm:"column:gas_price;type:decimal(40,18);not null;default:0.000000000000000000;comment:'燃料费价格,用于计算需要花费的基础币'" json:"gas_price"` // 燃料费价格,用于计算需要花费的基础币 + GasFee float64 `gorm:"column:gas_fee;type:decimal(40,18);not null;default:0.000000000000000000;comment:'实际转账燃料费'" json:"gas_fee"` // 实际转账燃料费 + SendCount int `gorm:"column:send_count;type:int;not null;comment:'广播交易次数'" json:"send_count"` // 广播交易次数 + SendAt time.Time `gorm:"column:send_at;type:timestamp;default:null;comment:'发送交易时间'" json:"send_at"` // 发送交易时间 + SendRemark string `gorm:"column:send_remark;type:varchar(255);not null;default:'';comment:'交易出错备注'" json:"send_remark"` // 交易出错备注 + CheckTimes int `gorm:"column:check_times;type:int;not null;default:0;comment:'查询结果次数'" json:"check_times"` // 查询结果次数 + CheckRemark string `gorm:"column:check_remark;type:varchar(255);not null;default:'';comment:'检查出错备注'" json:"check_remark"` // 检查出错备注 + SuccessAt time.Time `gorm:"column:success_at;type:timestamp;default:null;comment:'成功的时间'" json:"success_at"` // 成功的时间 + TxHash string `gorm:"index:tx_hash;column:tx_hash;type:varchar(80);not null;default:'';comment:'交易哈希'" json:"tx_hash"` // 交易哈希 + Status int8 `gorm:"column:status;type:tinyint;not null;default:0;comment:'订单状态:0待转账,1转账中,2发送成功待确认,3确认成功,4确认失败,5已退款,6已关闭'" json:"status"` // 订单状态:0待转账,1转账中,2发送成功待确认,3确认成功,4确认失败,5已退款,6已关闭 + CreatedAt time.Time `gorm:"column:created_at;type:timestamp;not null;default:CURRENT_TIMESTAMP;comment:'创建时间'" json:"created_at"` // 创建时间 + UpdatedAt time.Time `gorm:"column:updated_at;type:timestamp;not null;default:CURRENT_TIMESTAMP;comment:'更新时间'" json:"updated_at"` // 更新时间 +} + +// TableName get sql table name.获取数据库表名 +func (m *JcPaymentWithdraw) TableName() string { + return "jc_payment_withdraw" +} + +type IJcPaymentWithdraw interface { + GetID() uint64 + GetInvoiceCode() string + GetAppID() string + GetOrderID() string + GetUserID() string + GetUserType() int8 + GetFromAddress() string + GetToAddress() string + GetChainNet() string + GetToken() string + GetAmountInput() float64 + GetAmountCredited() float64 + GetGasToken() float64 + GetGasRate() float64 + GetUserFeeRate() float64 + GetGasLimit() float64 + GetGasPrice() float64 + GetGasFee() float64 + GetSendCount() int + GetSendAt() time.Time + GetSendRemark() string + GetCheckTimes() int + GetCheckRemark() string + GetSuccessAt() time.Time + GetTxHash() string + GetStatus() int8 + GetCreatedAt() time.Time + GetUpdatedAt() time.Time +} + +func (m *JcPaymentWithdraw) GetID() uint64 { + return m.ID +} + +func (m *JcPaymentWithdraw) GetInvoiceCode() string { + return m.InvoiceCode +} + +func (m *JcPaymentWithdraw) GetAppID() string { + return m.AppID +} + +func (m *JcPaymentWithdraw) GetOrderID() string { + return m.OrderID +} + +func (m *JcPaymentWithdraw) GetUserID() string { + return m.UserID +} + +func (m *JcPaymentWithdraw) GetUserType() int8 { + return m.UserType +} + +func (m *JcPaymentWithdraw) GetFromAddress() string { + return m.FromAddress +} + +func (m *JcPaymentWithdraw) GetToAddress() string { + return m.ToAddress +} + +func (m *JcPaymentWithdraw) GetChainNet() string { + return m.ChainNet +} + +func (m *JcPaymentWithdraw) GetToken() string { + return m.Token +} + +func (m *JcPaymentWithdraw) GetAmountInput() float64 { + return m.AmountInput +} + +func (m *JcPaymentWithdraw) GetAmountCredited() float64 { + return m.AmountCredited +} + +func (m *JcPaymentWithdraw) GetGasToken() float64 { + return m.GasToken +} + +func (m *JcPaymentWithdraw) GetGasRate() float64 { + return m.GasRate +} + +func (m *JcPaymentWithdraw) GetUserFeeRate() float64 { + return m.UserFeeRate +} + +func (m *JcPaymentWithdraw) GetGasLimit() float64 { + return m.GasLimit +} + +func (m *JcPaymentWithdraw) GetGasPrice() float64 { + return m.GasPrice +} + +func (m *JcPaymentWithdraw) GetGasFee() float64 { + return m.GasFee +} + +func (m *JcPaymentWithdraw) GetSendCount() int { + return m.SendCount +} + +func (m *JcPaymentWithdraw) GetSendAt() time.Time { + return m.SendAt +} + +func (m *JcPaymentWithdraw) GetSendRemark() string { + return m.SendRemark +} + +func (m *JcPaymentWithdraw) GetCheckTimes() int { + return m.CheckTimes +} + +func (m *JcPaymentWithdraw) GetCheckRemark() string { + return m.CheckRemark +} + +func (m *JcPaymentWithdraw) GetSuccessAt() time.Time { + return m.SuccessAt +} + +func (m *JcPaymentWithdraw) GetTxHash() string { + return m.TxHash +} + +func (m *JcPaymentWithdraw) GetStatus() int8 { + return m.Status +} + +func (m *JcPaymentWithdraw) GetCreatedAt() time.Time { + return m.CreatedAt +} + +func (m *JcPaymentWithdraw) GetUpdatedAt() time.Time { + return m.UpdatedAt +} + +// ToMap struct to map 结构体转成map +func (m *JcPaymentWithdraw) ToMap() map[string]any { + return map[string]any{ + "id": m.ID, + "invoice_code": m.InvoiceCode, + "app_id": m.AppID, + "order_id": m.OrderID, + "user_id": m.UserID, + "user_type": m.UserType, + "from_address": m.FromAddress, + "to_address": m.ToAddress, + "chain_net": m.ChainNet, + "token": m.Token, + "amount_input": m.AmountInput, + "amount_credited": m.AmountCredited, + "gas_token": m.GasToken, + "gas_rate": m.GasRate, + "user_fee_rate": m.UserFeeRate, + "gas_limit": m.GasLimit, + "gas_price": m.GasPrice, + "gas_fee": m.GasFee, + "send_count": m.SendCount, + "send_at": m.SendAt, + "send_remark": m.SendRemark, + "check_times": m.CheckTimes, + "check_remark": m.CheckRemark, + "success_at": m.SuccessAt, + "tx_hash": m.TxHash, + "status": m.Status, + "created_at": m.CreatedAt, + "updated_at": m.UpdatedAt, + } +} + +// ToMapWithoutModel struct to map 结构体转成map, 不带gorm.Model +func (m *JcPaymentWithdraw) ToMapWithoutModel() map[string]any { + return map[string]any{ + "invoice_code": m.InvoiceCode, + "app_id": m.AppID, + "order_id": m.OrderID, + "user_id": m.UserID, + "user_type": m.UserType, + "from_address": m.FromAddress, + "to_address": m.ToAddress, + "chain_net": m.ChainNet, + "token": m.Token, + "amount_input": m.AmountInput, + "amount_credited": m.AmountCredited, + "gas_token": m.GasToken, + "gas_rate": m.GasRate, + "user_fee_rate": m.UserFeeRate, + "gas_limit": m.GasLimit, + "gas_price": m.GasPrice, + "gas_fee": m.GasFee, + "send_count": m.SendCount, + "send_at": m.SendAt, + "send_remark": m.SendRemark, + "check_times": m.CheckTimes, + "check_remark": m.CheckRemark, + "success_at": m.SuccessAt, + "tx_hash": m.TxHash, + "status": m.Status, + } +} + +// JcPaymentWithdrawColumns get sql column name.获取数据库列名 +var JcPaymentWithdrawColumns = struct { + ID string + InvoiceCode string + AppID string + OrderID string + UserID string + UserType string + FromAddress string + ToAddress string + ChainNet string + Token string + AmountInput string + AmountCredited string + GasToken string + GasRate string + UserFeeRate string + GasLimit string + GasPrice string + GasFee string + SendCount string + SendAt string + SendRemark string + CheckTimes string + CheckRemark string + SuccessAt string + TxHash string + Status string + CreatedAt string + UpdatedAt string +}{ + ID: "id", + InvoiceCode: "invoice_code", + AppID: "app_id", + OrderID: "order_id", + UserID: "user_id", + UserType: "user_type", + FromAddress: "from_address", + ToAddress: "to_address", + ChainNet: "chain_net", + Token: "token", + AmountInput: "amount_input", + AmountCredited: "amount_credited", + GasToken: "gas_token", + GasRate: "gas_rate", + UserFeeRate: "user_fee_rate", + GasLimit: "gas_limit", + GasPrice: "gas_price", + GasFee: "gas_fee", + SendCount: "send_count", + SendAt: "send_at", + SendRemark: "send_remark", + CheckTimes: "check_times", + CheckRemark: "check_remark", + SuccessAt: "success_at", + TxHash: "tx_hash", + Status: "status", + CreatedAt: "created_at", + UpdatedAt: "updated_at", +} diff --git a/main.go b/main.go old mode 100644 new mode 100755 diff --git a/main_test.go b/main_test.go old mode 100644 new mode 100755 index 192325f..28fc79e --- a/main_test.go +++ b/main_test.go @@ -8,8 +8,8 @@ import ( "github.com/xxjwxc/gormt/data/view/model" ) -func TestMain(t *testing.T) { - str := `{"DbName":"oauth_db","PackageName":"model","TabList":[{"Name":"user_account_tbl","Notes":"用户账号","SQLBuildStr":"","Em":[{"Name":"id","Notes":"","Type":"int(11)","Index":[{"Key":1,"KeyName":""}],"IsNull":false,"ForeignKeyList":null},{"Name":"account","Notes":"","Type":"varchar(64)","Index":[{"Key":2,"KeyName":""}],"IsNull":false,"ForeignKeyList":null},{"Name":"password","Notes":"","Type":"varchar(64)","Index":null,"IsNull":false,"ForeignKeyList":null},{"Name":"account_type","Notes":"帐号类型:0手机号,1邮件","Type":"int(11)","Index":null,"IsNull":false,"ForeignKeyList":null},{"Name":"app_key","Notes":"authbucket_oauth2_client表的id","Type":"varchar(255)","Index":null,"IsNull":false,"ForeignKeyList":null},{"Name":"user_info_tbl_id","Notes":"","Type":"int(11)","Index":[{"Key":3,"KeyName":"user_info_id"}],"IsNull":false,"ForeignKeyList":[{"TableName":"user_info_tbl","ColumnName":"id"}]},{"Name":"reg_time","Notes":"","Type":"datetime","Index":null,"IsNull":true,"ForeignKeyList":null},{"Name":"reg_ip","Notes":"","Type":"varchar(15)","Index":[{"Key":3,"KeyName":"user_info_id"}],"IsNull":true,"ForeignKeyList":null},{"Name":"bundle_id","Notes":"","Type":"varchar(255)","Index":null,"IsNull":true,"ForeignKeyList":null},{"Name":"describ","Notes":"","Type":"varchar(255)","Index":null,"IsNull":true,"ForeignKeyList":null}]},{"Name":"user_info_tbl","Notes":"用户信息","SQLBuildStr":"","Em":[{"Name":"","Notes":"","Type":"gorm.Model","Index":null,"IsNull":false,"ForeignKeyList":null},{"Name":"nickname","Notes":"","Type":"varchar(32)","Index":null,"IsNull":false,"ForeignKeyList":null},{"Name":"headurl","Notes":"","Type":"varchar(255)","Index":null,"IsNull":true,"ForeignKeyList":null}]},{"Name":"oauth2_access_token","Notes":"token认证","SQLBuildStr":"","Em":[{"Name":"id","Notes":"","Type":"int(11)","Index":[{"Key":1,"KeyName":""}],"IsNull":false,"ForeignKeyList":null},{"Name":"access_token","Notes":"","Type":"varchar(255)","Index":[{"Key":2,"KeyName":""}],"IsNull":false,"ForeignKeyList":null},{"Name":"token_type","Notes":"","Type":"varchar(255)","Index":null,"IsNull":false,"ForeignKeyList":null},{"Name":"app_key","Notes":"key","Type":"varchar(255)","Index":null,"IsNull":false,"ForeignKeyList":null},{"Name":"username","Notes":"用户名","Type":"varchar(255)","Index":null,"IsNull":false,"ForeignKeyList":null},{"Name":"expires","Notes":"过期时间","Type":"datetime","Index":null,"IsNull":false,"ForeignKeyList":null}]},{"Name":"user","Notes":"","SQLBuildStr":"","Em":[{"Name":"userId","Notes":"","Type":"int(11)","Index":[{"Key":1,"KeyName":""}],"IsNull":false,"ForeignKeyList":null},{"Name":"name","Notes":"","Type":"varchar(30)","Index":null,"IsNull":false,"ForeignKeyList":null},{"Name":"sex","Notes":"","Type":"int(11)","Index":[{"Key":3,"KeyName":""}],"IsNull":false,"ForeignKeyList":null},{"Name":"job","Notes":"","Type":"int(11)","Index":null,"IsNull":false,"ForeignKeyList":null}]},{"Name":"organ","Notes":"","SQLBuildStr":"","Em":[{"Name":"id","Notes":"","Type":"int(11)","Index":[{"Key":1,"KeyName":""}],"IsNull":false,"ForeignKeyList":null},{"Name":"userId","Notes":"","Type":"int(11)","Index":[{"Key":3,"KeyName":""}],"IsNull":true,"ForeignKeyList":[{"TableName":"user","ColumnName":"sex"}]},{"Name":"type","Notes":"","Type":"int(11)","Index":null,"IsNull":true,"ForeignKeyList":null},{"Name":"score","Notes":"","Type":"int(11)","Index":null,"IsNull":true,"ForeignKeyList":null}]},{"Name":"sign_client_tbl","Notes":"","SQLBuildStr":"","Em":[{"Name":"id","Notes":"","Type":"int(11)","Index":[{"Key":1,"KeyName":""}],"IsNull":false,"ForeignKeyList":null},{"Name":"app_key","Notes":"","Type":"varchar(255)","Index":null,"IsNull":false,"ForeignKeyList":null},{"Name":"app_secret","Notes":"","Type":"varchar(255)","Index":null,"IsNull":false,"ForeignKeyList":null},{"Name":"expire_time","Notes":"超时时间","Type":"datetime","Index":null,"IsNull":false,"ForeignKeyList":null},{"Name":"strict_sign","Notes":"是否强制验签:0:用户自定义,1:强制","Type":"int(255)","Index":null,"IsNull":true,"ForeignKeyList":null},{"Name":"strict_verify","Notes":"是否强制验证码:0:用户自定义,1:强制","Type":"int(11)","Index":null,"IsNull":false,"ForeignKeyList":null},{"Name":"token_expire_time","Notes":"token过期时间","Type":"int(11)","Index":null,"IsNull":false,"ForeignKeyList":null}]},{"Name":"user_paybill_order","Notes":"","SQLBuildStr":"","Em":[{"Name":"id","Notes":"","Type":"int(11)","Index":[{"Key":1,"KeyName":""}],"IsNull":false,"ForeignKeyList":null},{"Name":"paybill_id","Notes":"二次账单id","Type":"bigint(20)","Index":[{"Key":3,"KeyName":"order_id"}],"IsNull":false,"ForeignKeyList":null},{"Name":"order_id_mysql","Notes":"MySql中的订单Id","Type":"bigint(20)","Index":[{"Key":3,"KeyName":"order_id"}],"IsNull":false,"ForeignKeyList":null},{"Name":"order_item_id_mysql","Notes":"MySql中的订单ItemId","Type":"bigint(20)","Index":[{"Key":3,"KeyName":"order_id"}],"IsNull":false,"ForeignKeyList":null},{"Name":"order_id_mssql","Notes":"MsSql中的订单Id","Type":"bigint(20)","Index":null,"IsNull":false,"ForeignKeyList":null}]},{"Name":"oauth2_client_tbl","Notes":"client key 信息","SQLBuildStr":"","Em":[{"Name":"id","Notes":"","Type":"int(11)","Index":[{"Key":1,"KeyName":""}],"IsNull":false,"ForeignKeyList":null},{"Name":"app_key","Notes":"","Type":"varchar(255)","Index":null,"IsNull":false,"ForeignKeyList":null},{"Name":"app_secret","Notes":"","Type":"varchar(255)","Index":null,"IsNull":false,"ForeignKeyList":null},{"Name":"expire_time","Notes":"超时时间","Type":"datetime","Index":null,"IsNull":false,"ForeignKeyList":null},{"Name":"strict_sign","Notes":"是否强制验签:0:用户自定义,1:强制","Type":"int(255)","Index":null,"IsNull":true,"ForeignKeyList":null},{"Name":"strict_verify","Notes":"是否强制验证码:0:用户自定义,1:强制","Type":"int(11)","Index":null,"IsNull":false,"ForeignKeyList":null},{"Name":"token_expire_time","Notes":"token过期时间","Type":"int(11)","Index":null,"IsNull":false,"ForeignKeyList":null},{"Name":"aaa","Notes":"","Type":"json","Index":null,"IsNull":true,"ForeignKeyList":null}]},{"Name":"oauth2_refresh_token","Notes":"刷新token","SQLBuildStr":"","Em":[{"Name":"id","Notes":"","Type":"int(11)","Index":[{"Key":1,"KeyName":""}],"IsNull":false,"ForeignKeyList":null},{"Name":"refresh_token","Notes":"","Type":"varchar(255)","Index":[{"Key":2,"KeyName":""}],"IsNull":false,"ForeignKeyList":null},{"Name":"token_type","Notes":"","Type":"varchar(255)","Index":null,"IsNull":false,"ForeignKeyList":null},{"Name":"app_key","Notes":"","Type":"varchar(255)","Index":null,"IsNull":false,"ForeignKeyList":null},{"Name":"username","Notes":"","Type":"varchar(255)","Index":null,"IsNull":false,"ForeignKeyList":null},{"Name":"expires","Notes":"","Type":"datetime","Index":null,"IsNull":false,"ForeignKeyList":null},{"Name":"token_expire_time","Notes":"","Type":"int(11)","Index":null,"IsNull":false,"ForeignKeyList":null}]}]}` +func TestMain(m *testing.M) { + str := `{"DbName":"oauth_db","PackageName":"model","TabList":[{"ChainType":"user_account_tbl","Notes":"用户账号","SQLBuildStr":"","Em":[{"ChainType":"id","Notes":"","Type":"int(11)","Index":[{"Key":1,"KeyName":""}],"IsNull":false,"ForeignKeyList":null},{"ChainType":"account","Notes":"","Type":"varchar(64)","Index":[{"Key":2,"KeyName":""}],"IsNull":false,"ForeignKeyList":null},{"ChainType":"password","Notes":"","Type":"varchar(64)","Index":null,"IsNull":false,"ForeignKeyList":null},{"ChainType":"account_type","Notes":"帐号类型:0手机号,1邮件","Type":"int(11)","Index":null,"IsNull":false,"ForeignKeyList":null},{"ChainType":"app_key","Notes":"authbucket_oauth2_client表的id","Type":"varchar(255)","Index":null,"IsNull":false,"ForeignKeyList":null},{"ChainType":"user_info_tbl_id","Notes":"","Type":"int(11)","Index":[{"Key":3,"KeyName":"user_info_id"}],"IsNull":false,"ForeignKeyList":[{"TableName":"user_info_tbl","ColumnName":"id"}]},{"ChainType":"reg_time","Notes":"","Type":"datetime","Index":null,"IsNull":true,"ForeignKeyList":null},{"ChainType":"reg_ip","Notes":"","Type":"varchar(15)","Index":[{"Key":3,"KeyName":"user_info_id"}],"IsNull":true,"ForeignKeyList":null},{"ChainType":"bundle_id","Notes":"","Type":"varchar(255)","Index":null,"IsNull":true,"ForeignKeyList":null},{"ChainType":"describ","Notes":"","Type":"varchar(255)","Index":null,"IsNull":true,"ForeignKeyList":null}]},{"ChainType":"user_info_tbl","Notes":"用户信息","SQLBuildStr":"","Em":[{"ChainType":"","Notes":"","Type":"gorm.Model","Index":null,"IsNull":false,"ForeignKeyList":null},{"ChainType":"nickname","Notes":"","Type":"varchar(32)","Index":null,"IsNull":false,"ForeignKeyList":null},{"ChainType":"headurl","Notes":"","Type":"varchar(255)","Index":null,"IsNull":true,"ForeignKeyList":null}]},{"ChainType":"oauth2_access_token","Notes":"token认证","SQLBuildStr":"","Em":[{"ChainType":"id","Notes":"","Type":"int(11)","Index":[{"Key":1,"KeyName":""}],"IsNull":false,"ForeignKeyList":null},{"ChainType":"access_token","Notes":"","Type":"varchar(255)","Index":[{"Key":2,"KeyName":""}],"IsNull":false,"ForeignKeyList":null},{"ChainType":"token_type","Notes":"","Type":"varchar(255)","Index":null,"IsNull":false,"ForeignKeyList":null},{"ChainType":"app_key","Notes":"key","Type":"varchar(255)","Index":null,"IsNull":false,"ForeignKeyList":null},{"ChainType":"username","Notes":"用户名","Type":"varchar(255)","Index":null,"IsNull":false,"ForeignKeyList":null},{"ChainType":"expires","Notes":"过期时间","Type":"datetime","Index":null,"IsNull":false,"ForeignKeyList":null}]},{"ChainType":"user","Notes":"","SQLBuildStr":"","Em":[{"ChainType":"userId","Notes":"","Type":"int(11)","Index":[{"Key":1,"KeyName":""}],"IsNull":false,"ForeignKeyList":null},{"ChainType":"name","Notes":"","Type":"varchar(30)","Index":null,"IsNull":false,"ForeignKeyList":null},{"ChainType":"sex","Notes":"","Type":"int(11)","Index":[{"Key":3,"KeyName":""}],"IsNull":false,"ForeignKeyList":null},{"ChainType":"job","Notes":"","Type":"int(11)","Index":null,"IsNull":false,"ForeignKeyList":null}]},{"ChainType":"organ","Notes":"","SQLBuildStr":"","Em":[{"ChainType":"id","Notes":"","Type":"int(11)","Index":[{"Key":1,"KeyName":""}],"IsNull":false,"ForeignKeyList":null},{"ChainType":"userId","Notes":"","Type":"int(11)","Index":[{"Key":3,"KeyName":""}],"IsNull":true,"ForeignKeyList":[{"TableName":"user","ColumnName":"sex"}]},{"ChainType":"type","Notes":"","Type":"int(11)","Index":null,"IsNull":true,"ForeignKeyList":null},{"ChainType":"score","Notes":"","Type":"int(11)","Index":null,"IsNull":true,"ForeignKeyList":null}]},{"ChainType":"sign_client_tbl","Notes":"","SQLBuildStr":"","Em":[{"ChainType":"id","Notes":"","Type":"int(11)","Index":[{"Key":1,"KeyName":""}],"IsNull":false,"ForeignKeyList":null},{"ChainType":"app_key","Notes":"","Type":"varchar(255)","Index":null,"IsNull":false,"ForeignKeyList":null},{"ChainType":"app_secret","Notes":"","Type":"varchar(255)","Index":null,"IsNull":false,"ForeignKeyList":null},{"ChainType":"expire_time","Notes":"超时时间","Type":"datetime","Index":null,"IsNull":false,"ForeignKeyList":null},{"ChainType":"strict_sign","Notes":"是否强制验签:0:用户自定义,1:强制","Type":"int(255)","Index":null,"IsNull":true,"ForeignKeyList":null},{"ChainType":"strict_verify","Notes":"是否强制验证码:0:用户自定义,1:强制","Type":"int(11)","Index":null,"IsNull":false,"ForeignKeyList":null},{"ChainType":"token_expire_time","Notes":"token过期时间","Type":"int(11)","Index":null,"IsNull":false,"ForeignKeyList":null}]},{"ChainType":"user_paybill_order","Notes":"","SQLBuildStr":"","Em":[{"ChainType":"id","Notes":"","Type":"int(11)","Index":[{"Key":1,"KeyName":""}],"IsNull":false,"ForeignKeyList":null},{"ChainType":"paybill_id","Notes":"二次账单id","Type":"bigint(20)","Index":[{"Key":3,"KeyName":"order_id"}],"IsNull":false,"ForeignKeyList":null},{"ChainType":"order_id_mysql","Notes":"MySql中的订单Id","Type":"bigint(20)","Index":[{"Key":3,"KeyName":"order_id"}],"IsNull":false,"ForeignKeyList":null},{"ChainType":"order_item_id_mysql","Notes":"MySql中的订单ItemId","Type":"bigint(20)","Index":[{"Key":3,"KeyName":"order_id"}],"IsNull":false,"ForeignKeyList":null},{"ChainType":"order_id_mssql","Notes":"MsSql中的订单Id","Type":"bigint(20)","Index":null,"IsNull":false,"ForeignKeyList":null}]},{"ChainType":"oauth2_client_tbl","Notes":"client key 信息","SQLBuildStr":"","Em":[{"ChainType":"id","Notes":"","Type":"int(11)","Index":[{"Key":1,"KeyName":""}],"IsNull":false,"ForeignKeyList":null},{"ChainType":"app_key","Notes":"","Type":"varchar(255)","Index":null,"IsNull":false,"ForeignKeyList":null},{"ChainType":"app_secret","Notes":"","Type":"varchar(255)","Index":null,"IsNull":false,"ForeignKeyList":null},{"ChainType":"expire_time","Notes":"超时时间","Type":"datetime","Index":null,"IsNull":false,"ForeignKeyList":null},{"ChainType":"strict_sign","Notes":"是否强制验签:0:用户自定义,1:强制","Type":"int(255)","Index":null,"IsNull":true,"ForeignKeyList":null},{"ChainType":"strict_verify","Notes":"是否强制验证码:0:用户自定义,1:强制","Type":"int(11)","Index":null,"IsNull":false,"ForeignKeyList":null},{"ChainType":"token_expire_time","Notes":"token过期时间","Type":"int(11)","Index":null,"IsNull":false,"ForeignKeyList":null},{"ChainType":"aaa","Notes":"","Type":"json","Index":null,"IsNull":true,"ForeignKeyList":null}]},{"ChainType":"oauth2_refresh_token","Notes":"刷新token","SQLBuildStr":"","Em":[{"ChainType":"id","Notes":"","Type":"int(11)","Index":[{"Key":1,"KeyName":""}],"IsNull":false,"ForeignKeyList":null},{"ChainType":"refresh_token","Notes":"","Type":"varchar(255)","Index":[{"Key":2,"KeyName":""}],"IsNull":false,"ForeignKeyList":null},{"ChainType":"token_type","Notes":"","Type":"varchar(255)","Index":null,"IsNull":false,"ForeignKeyList":null},{"ChainType":"app_key","Notes":"","Type":"varchar(255)","Index":null,"IsNull":false,"ForeignKeyList":null},{"ChainType":"username","Notes":"","Type":"varchar(255)","Index":null,"IsNull":false,"ForeignKeyList":null},{"ChainType":"expires","Notes":"","Type":"datetime","Index":null,"IsNull":false,"ForeignKeyList":null},{"ChainType":"token_expire_time","Notes":"","Type":"int(11)","Index":null,"IsNull":false,"ForeignKeyList":null}]}]}` var pkg model.DBInfo json.Unmarshal([]byte(str), &pkg) // out, _ := json.Marshal(pkg) diff --git a/prompt.go b/prompt.go new file mode 100755 index 0000000..f3842de --- /dev/null +++ b/prompt.go @@ -0,0 +1,31 @@ +package gormt + +import ( + "time" +) + +// Prompt [...] +type Prompt struct { +} + +// TableName get sql table name.获取数据库表名 +func (m *Prompt) TableName() string { + return "prompt" +} + +type IPrompt interface { +} + +// ToMap struct to map 结构体转成map +func (m *Prompt) ToMap() map[string]any { + return map[string]any{} +} + +// ToMapWithoutModel struct to map 结构体转成map, 不带gorm.Model +func (m *Prompt) ToMapWithoutModel() map[string]any { + return map[string]any{} +} + +// PromptColumns get sql column name.获取数据库列名 +var PromptColumns = struct { +}{} diff --git a/sql.yml b/sql.yml old mode 100644 new mode 100755