From 8585c30fbd0ac2883499683c5c7b4624f7d68683 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B0=A2=E5=B0=8F=E5=86=9B?= Date: Fri, 21 Feb 2020 02:21:17 +0800 Subject: [PATCH] fix gorm.SingularTable model MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修复 gorm.SingularTable 表名复数问题 --- README.md | 2 +- config.yml | 2 +- data/config/test_def.go | 2 +- doc/export.md | 24 ------------------------ doc/export_cn.md | 24 ------------------------ 5 files changed, 3 insertions(+), 51 deletions(-) diff --git a/README.md b/README.md index 1d15009..a090fb7 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,7 @@ out_dir : "." # out dir url_tag : json # web url tag(json,db(https://github.com/google/go-querystring)) language : # language(English,中 文) db_tag : gorm # DB tag(gorm,db) -singular_table : false # Table name plural (big Camel-Case):gorm.SingularTable +singular_table : true # Table name plural (big Camel-Case):gorm.SingularTable simple : false #simple output is_out_sql : false # Whether to output sql is_out_func : true # Whether to output function diff --git a/config.yml b/config.yml index ee706a4..52029ab 100644 --- a/config.yml +++ b/config.yml @@ -4,7 +4,7 @@ out_dir : ./model # 输出目录 url_tag : json # web url tag(json,db(https://github.com/google/go-querystring)) language : # 语言(English,中 文) db_tag : gorm # 数据库标签(gorm,db) -singular_table : true # 单表模式:true:禁用表名复数,false:采用表明复数 参考:gorm.SingularTable +singular_table : true # 单表模式:true:禁用表名复数,false:采用表名复数 参考:gorm.SingularTable simple : false # 简单输出(默认gorm标签不输出) is_out_sql : false # 是否输出 sql 原信息 is_out_func : true # 是否输出 快捷函数 diff --git a/data/config/test_def.go b/data/config/test_def.go index 9e53c51..476449a 100644 --- a/data/config/test_def.go +++ b/data/config/test_def.go @@ -13,7 +13,7 @@ service_displayname : #服务显示名 sercice_desc : #服务描述 is_dev : false # 是否开发者模式 out_dir : ./db # 输出目录 -singular_table : false # 单表模式:true:禁用表名复数,false:采用表明复数 参考:gorm.SingularTable +singular_table : true # 单表模式:true:禁用表名复数,false:采用表明复数 参考:gorm.SingularTable simple : true #简单输出 isJsonTag : true #是否打json标记 mysql_info: diff --git a/doc/export.md b/doc/export.md index 2b7c4a9..cef3192 100644 --- a/doc/export.md +++ b/doc/export.md @@ -58,30 +58,6 @@ type UserAccountTbl struct { ------------- -### Complex single table mode export - -- param:singular_table = true simple = false is_foreign_key = false - -###### --->export result - -``` -// UserAccountTbl 用户账号 -type User_account_tbl struct { - Id int `gorm:"primary_key;column:id;type:int(11);not null" json:"-"` - Account string `gorm:"unique;column:account;type:varchar(64);not null" json:"account"` - Password string `gorm:"column:password;type:varchar(64);not null" json:"password"` - Account_type int `gorm:"column:account_type;type:int(11);not null" json:"account_type"` // 帐号类型:0手机号,1邮件 - App_key string `gorm:"unique_index:UNIQ_5696AD037D3656A4;column:app_key;type:varchar(255);not null" json:"app_key"` // authbucket_oauth2_client表的id - User_info_tbl_id int `gorm:"unique_index:UNIQ_5696AD037D3656A4;index;column:user_info_tbl_id;type:int(11);not null" json:"user_info_tbl_id"` - Reg_time time.Time `gorm:"column:reg_time;type:datetime" json:"reg_time"` - Reg_ip string `gorm:"column:reg_ip;type:varchar(15)" json:"reg_ip"` - Bundle_id string `gorm:"column:bundle_id;type:varchar(255)" json:"bundle_id"` - Describ string `gorm:"column:describ;type:varchar(255)" json:"describ"` -} -``` - -------------- - ### Simple-export-with-JSON - param:singular_table = false simple = true is_json_tag = true is_foreign_key = false diff --git a/doc/export_cn.md b/doc/export_cn.md index 4d15a62..f643d61 100644 --- a/doc/export_cn.md +++ b/doc/export_cn.md @@ -58,30 +58,6 @@ type UserAccountTbl struct { ------------- -### 复杂单表模式导出 - -- 参数:singular_table = true simple = false is_foreign_key = false - -###### --->导出结果 - -``` -// UserAccountTbl 用户账号 -type User_account_tbl struct { - Id int `gorm:"primary_key;column:id;type:int(11);not null" json:"-"` - Account string `gorm:"unique;column:account;type:varchar(64);not null" json:"account"` - Password string `gorm:"column:password;type:varchar(64);not null" json:"password"` - Account_type int `gorm:"column:account_type;type:int(11);not null" json:"account_type"` // 帐号类型:0手机号,1邮件 - App_key string `gorm:"unique_index:UNIQ_5696AD037D3656A4;column:app_key;type:varchar(255);not null" json:"app_key"` // authbucket_oauth2_client表的id - User_info_tbl_id int `gorm:"unique_index:UNIQ_5696AD037D3656A4;index;column:user_info_tbl_id;type:int(11);not null" json:"user_info_tbl_id"` - Reg_time time.Time `gorm:"column:reg_time;type:datetime" json:"reg_time"` - Reg_ip string `gorm:"column:reg_ip;type:varchar(15)" json:"reg_ip"` - Bundle_id string `gorm:"column:bundle_id;type:varchar(255)" json:"bundle_id"` - Describ string `gorm:"column:describ;type:varchar(255)" json:"describ"` -} -``` - -------------- - ### 简单带json导出 - 参数:singular_table = false simple = true is_json_tag = true is_foreign_key = false