Merge pull request #179 from redbirdztc/feature-use-gorm-model-or-not

feature: model是否使用gorm.Model
This commit is contained in:
xxj
2021-12-08 19:05:42 +08:00
committed by GitHub
6 changed files with 20 additions and 12 deletions

View File

@@ -12,9 +12,10 @@ type Config struct {
CfgBase `yaml:"base"`
DBInfo DBInfo `yaml:"db_info"`
OutDir string `yaml:"out_dir"`
URLTag string `yaml:"url_tag"` // url tag
Language string `yaml:"language"` // language
DbTag string `yaml:"db_tag"` // 数据库标签gormt,db
URLTag string `yaml:"url_tag"` // url tag
Language string `yaml:"language"` // language
DbTag string `yaml:"db_tag"` // 数据库标签gormt,db
UserGormModel bool `yaml:"user_gorm_model"` //model是否使用gorm.Model
Simple bool `yaml:"simple"`
IsWEBTag bool `yaml:"is_web_tag"`
IsWebTagPkHidden bool `yaml:"is_web_tag_pk_hidden"` // web标记是否隐藏主键
@@ -209,6 +210,11 @@ func SetDBTag(s string) {
_map.DbTag = s
}
// GetUserGormModel get `use gorm.Model or not`.
func GetUserGormModel() bool {
return _map.UserGormModel
}
// SetIsNullToPoint if with null to porint in struct
func SetIsNullToPoint(b bool) {
_map.IsNullToPoint = b

View File

@@ -32,12 +32,13 @@ var _map = Config{
Password: "root",
Database: "test",
},
OutDir: "./model",
URLTag: "json",
Language: "中 文",
DbTag: "gorm",
Simple: false,
IsWEBTag: false,
OutDir: "./model",
URLTag: "json",
Language: "中 文",
DbTag: "gorm",
UserGormModel: false,
Simple: false,
IsWEBTag: false,
// SingularTable: true,
IsForeignKey: true,
IsOutSQL: false,

View File

@@ -11,7 +11,7 @@ import (
// filterModel filter.过滤 gorm.Model
func filterModel(list *[]genColumns) bool {
if config.GetDBTag() != "gorm" {
if config.GetDBTag() != "gorm" || !config.GetUserGormModel() {
return false
}

View File

@@ -11,7 +11,7 @@ import (
// filterModel filter.过滤 gorm.Model
func filterModel(list *[]genColumns) bool {
if config.GetDBTag() != "gorm" {
if config.GetDBTag() != "gorm" || !config.GetUserGormModel() {
return false
}

View File

@@ -10,7 +10,7 @@ import (
// filterModel filter.过滤 gorm.Model
func filterModel(list *[]genColumns) bool {
if config.GetDBTag() != "gorm" {
if config.GetDBTag() != "gorm" || !config.GetUserGormModel() {
return false
}