Merge pull request #179 from redbirdztc/feature-use-gorm-model-or-not
feature: model是否使用gorm.Model
This commit is contained in:
@@ -5,6 +5,7 @@ url_tag : json # web url tag(json,db(https://github.com/google/go-querystring))
|
|||||||
language : # 语言(English,中 文)
|
language : # 语言(English,中 文)
|
||||||
db_tag : gorm # 数据库标签名(gorm,db)
|
db_tag : gorm # 数据库标签名(gorm,db)
|
||||||
simple : true # 简单输出(默认只输出gorm主键和字段标签)
|
simple : true # 简单输出(默认只输出gorm主键和字段标签)
|
||||||
|
use_gorm_model : false # model是否使用gorm.Model
|
||||||
is_db_tag : true # 是否输出 数据库标签(gorm,db)
|
is_db_tag : true # 是否输出 数据库标签(gorm,db)
|
||||||
is_out_sql : false # 是否输出 sql 原信息
|
is_out_sql : false # 是否输出 sql 原信息
|
||||||
is_out_func : true # 是否输出 快捷函数
|
is_out_func : true # 是否输出 快捷函数
|
||||||
|
|||||||
@@ -12,9 +12,10 @@ type Config struct {
|
|||||||
CfgBase `yaml:"base"`
|
CfgBase `yaml:"base"`
|
||||||
DBInfo DBInfo `yaml:"db_info"`
|
DBInfo DBInfo `yaml:"db_info"`
|
||||||
OutDir string `yaml:"out_dir"`
|
OutDir string `yaml:"out_dir"`
|
||||||
URLTag string `yaml:"url_tag"` // url tag
|
URLTag string `yaml:"url_tag"` // url tag
|
||||||
Language string `yaml:"language"` // language
|
Language string `yaml:"language"` // language
|
||||||
DbTag string `yaml:"db_tag"` // 数据库标签(gormt,db)
|
DbTag string `yaml:"db_tag"` // 数据库标签(gormt,db)
|
||||||
|
UserGormModel bool `yaml:"user_gorm_model"` //model是否使用gorm.Model
|
||||||
Simple bool `yaml:"simple"`
|
Simple bool `yaml:"simple"`
|
||||||
IsWEBTag bool `yaml:"is_web_tag"`
|
IsWEBTag bool `yaml:"is_web_tag"`
|
||||||
IsWebTagPkHidden bool `yaml:"is_web_tag_pk_hidden"` // web标记是否隐藏主键
|
IsWebTagPkHidden bool `yaml:"is_web_tag_pk_hidden"` // web标记是否隐藏主键
|
||||||
@@ -209,6 +210,11 @@ func SetDBTag(s string) {
|
|||||||
_map.DbTag = s
|
_map.DbTag = s
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetUserGormModel get `use gorm.Model or not`.
|
||||||
|
func GetUserGormModel() bool {
|
||||||
|
return _map.UserGormModel
|
||||||
|
}
|
||||||
|
|
||||||
// SetIsNullToPoint if with null to porint in struct
|
// SetIsNullToPoint if with null to porint in struct
|
||||||
func SetIsNullToPoint(b bool) {
|
func SetIsNullToPoint(b bool) {
|
||||||
_map.IsNullToPoint = b
|
_map.IsNullToPoint = b
|
||||||
|
|||||||
@@ -32,12 +32,13 @@ var _map = Config{
|
|||||||
Password: "root",
|
Password: "root",
|
||||||
Database: "test",
|
Database: "test",
|
||||||
},
|
},
|
||||||
OutDir: "./model",
|
OutDir: "./model",
|
||||||
URLTag: "json",
|
URLTag: "json",
|
||||||
Language: "中 文",
|
Language: "中 文",
|
||||||
DbTag: "gorm",
|
DbTag: "gorm",
|
||||||
Simple: false,
|
UserGormModel: false,
|
||||||
IsWEBTag: false,
|
Simple: false,
|
||||||
|
IsWEBTag: false,
|
||||||
// SingularTable: true,
|
// SingularTable: true,
|
||||||
IsForeignKey: true,
|
IsForeignKey: true,
|
||||||
IsOutSQL: false,
|
IsOutSQL: false,
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import (
|
|||||||
|
|
||||||
// filterModel filter.过滤 gorm.Model
|
// filterModel filter.过滤 gorm.Model
|
||||||
func filterModel(list *[]genColumns) bool {
|
func filterModel(list *[]genColumns) bool {
|
||||||
if config.GetDBTag() != "gorm" {
|
if config.GetDBTag() != "gorm" || !config.GetUserGormModel() {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import (
|
|||||||
|
|
||||||
// filterModel filter.过滤 gorm.Model
|
// filterModel filter.过滤 gorm.Model
|
||||||
func filterModel(list *[]genColumns) bool {
|
func filterModel(list *[]genColumns) bool {
|
||||||
if config.GetDBTag() != "gorm" {
|
if config.GetDBTag() != "gorm" || !config.GetUserGormModel() {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import (
|
|||||||
|
|
||||||
// filterModel filter.过滤 gorm.Model
|
// filterModel filter.过滤 gorm.Model
|
||||||
func filterModel(list *[]genColumns) bool {
|
func filterModel(list *[]genColumns) bool {
|
||||||
if config.GetDBTag() != "gorm" {
|
if config.GetDBTag() != "gorm" || !config.GetUserGormModel() {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user