Skip to content

Commit

Permalink
add autoIncrement
Browse files Browse the repository at this point in the history
  • Loading branch information
xxjwxc committed Jul 6, 2022
1 parent fc112a7 commit 3dea08f
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 1 deletion.
3 changes: 2 additions & 1 deletion data/view/model/def.go
Original file line number Diff line number Diff line change
Expand Up @@ -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列表
Expand Down Expand Up @@ -117,7 +118,7 @@ type funDef struct {
Em []EmInfo // index 列表
Primary []FList // primary unique
Index []FList // index
IsOutPage bool // 是否开启分页
IsOutPage bool // 是否开启分页
}

//
1 change: 1 addition & 0 deletions data/view/model/genmysql/def.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
}

Expand Down
1 change: 1 addition & 0 deletions data/view/model/genmysql/genmysql.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
3 changes: 3 additions & 0 deletions data/view/model/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 3dea08f

Please sign in to comment.