add autoIncrement

master
xxj 2 years ago
parent fc112a736b
commit 3dea08f1e4

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

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

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

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

Loading…
Cancel
Save