This commit is contained in:
xxj
2022-07-05 20:35:17 +08:00
parent f47811a170
commit aa53e84c49
4 changed files with 7 additions and 1 deletions

View File

@@ -39,6 +39,7 @@ type TabInfo struct {
type ColumnsInfo struct { type ColumnsInfo struct {
BaseInfo BaseInfo
IsNull bool // null if db is set null IsNull bool // null if db is set null
Extra string // Extra (AUTO_INCREMENT 自增加)
Type string // Type.类型标记 Type string // Type.类型标记
Gormt string // 默认值 Gormt string // 默认值
Index []KList // index list.index列表 Index []KList // index list.index列表

View File

@@ -16,6 +16,7 @@ type genColumns struct {
Key string `gorm:"column:Key"` Key string `gorm:"column:Key"`
Desc string `gorm:"column:Comment"` Desc string `gorm:"column:Comment"`
Null string `gorm:"column:Null"` Null string `gorm:"column:Null"`
Extra string `gorm:"Extra"`
Default *string `gorm:"column:Default"` Default *string `gorm:"column:Default"`
} }

View File

@@ -153,6 +153,7 @@ func (m *mysqlModel) getTableElement(orm *mysqldb.MySqlDB, tab string) (el []mod
var tmp model.ColumnsInfo var tmp model.ColumnsInfo
tmp.Name = v.Field tmp.Name = v.Field
tmp.Type = v.Type tmp.Type = v.Type
tmp.Extra = v.Extra
FixNotes(&tmp, v.Desc) // 分析表注释 FixNotes(&tmp, v.Desc) // 分析表注释
if v.Default != nil { if v.Default != nil {

View File

@@ -140,6 +140,9 @@ func (m *_Model) genTableElement(cols []ColumnsInfo) (el []genstruct.GenElement)
if len(_tagGorm) > 0 { if len(_tagGorm) > 0 {
// not simple output. 默认只输出gorm主键和字段标签 // not simple output. 默认只输出gorm主键和字段标签
if !config.GetSimple() { if !config.GetSimple() {
if strings.EqualFold(v.Extra, "auto_increment") {
tmp.AddTag(_tagGorm, "autoIncrement:true")
}
for _, v1 := range v.Index { for _, v1 := range v.Index {
switch v1.Key { switch v1.Key {
// case ColumnsKeyDefault: // case ColumnsKeyDefault: