Merge branch 'master' of https://github.com/xxjwxc/gormt
This commit is contained in:
@@ -25,7 +25,8 @@ type Config struct {
|
||||
IsGUI bool `yaml:"is_gui"` //
|
||||
IsTableName bool `yaml:"is_table_name"`
|
||||
IsNullToPoint bool `yaml:"is_null_to_point"` // null to porint
|
||||
TablePrefix string `yaml:"table_prefix"` // 表前缀
|
||||
IsNullToSqlNull bool `yaml:"is_null_to_sql_null"`
|
||||
TablePrefix string `yaml:"table_prefix"` // 表前缀
|
||||
SelfTypeDef map[string]string `yaml:"self_type_define"`
|
||||
OutFileName string `yaml:"out_file_name"`
|
||||
WebTagType int `yaml:"web_tag_type"` // 默认小驼峰
|
||||
@@ -226,6 +227,14 @@ func GetIsNullToPoint() bool {
|
||||
return _map.IsNullToPoint
|
||||
}
|
||||
|
||||
func SetIsNullToSqlNull(b bool) {
|
||||
_map.IsNullToSqlNull = b
|
||||
}
|
||||
|
||||
func GetIsNullToSqlNull() bool {
|
||||
return _map.IsNullToSqlNull
|
||||
}
|
||||
|
||||
// SetTablePrefix set table prefix
|
||||
func SetTablePrefix(t string) {
|
||||
_map.TablePrefix = t
|
||||
|
||||
@@ -20,7 +20,7 @@ func getCamelName(name string) string {
|
||||
// return mybigcamel.Marshal(strings.TrimSuffix(name, "s"))
|
||||
// }
|
||||
|
||||
return mybigcamel.Marshal(name)
|
||||
return mybigcamel.Marshal(strings.ToLower(name))
|
||||
}
|
||||
|
||||
// titleCase title case.首字母大写
|
||||
@@ -113,6 +113,30 @@ func fixNullToPorint(name string, isNull bool) string {
|
||||
return "*" + name
|
||||
}
|
||||
}
|
||||
if isNull && config.GetIsNullToSqlNull() {
|
||||
|
||||
if strings.HasPrefix(name, "uint") {
|
||||
return "sql.NullInt64"
|
||||
}
|
||||
if strings.HasPrefix(name, "int") {
|
||||
return "sql.NullInt32"
|
||||
}
|
||||
if strings.HasPrefix(name, "float") {
|
||||
return "sql.NullFloat64"
|
||||
}
|
||||
if strings.HasPrefix(name, "date") {
|
||||
return "sql.NullTime"
|
||||
}
|
||||
if strings.HasPrefix(name, "time") {
|
||||
return "sql.NullTime"
|
||||
}
|
||||
if strings.HasPrefix(name, "bool") {
|
||||
return "sql.NullBool"
|
||||
}
|
||||
if strings.HasPrefix(name, "string") {
|
||||
return "sql.NullString"
|
||||
}
|
||||
}
|
||||
|
||||
return name
|
||||
}
|
||||
@@ -157,7 +181,7 @@ func getGormModelElement() []EmInfo {
|
||||
result = append(result, EmInfo{
|
||||
IsMulti: false,
|
||||
Notes: "deleted time",
|
||||
Type: "time.Time", // Type.类型标记
|
||||
Type: "gorm.DeletedAt", // Type.类型标记
|
||||
ColName: "deleted_at",
|
||||
ColNameEx: "deleted_at",
|
||||
ColStructName: "DeletedAt",
|
||||
|
||||
Reference in New Issue
Block a user