|
|
|
@ -123,7 +123,9 @@ func (m *_Model) genTableElement(cols []ColumnsInfo) (el []genstruct.GenElement)
|
|
|
|
|
tmp.SetName(getCamelName(v.Name))
|
|
|
|
|
tmp.SetNotes(v.Notes)
|
|
|
|
|
tmp.SetType(getTypeName(v.Type, v.IsNull))
|
|
|
|
|
// not simple output. 默认不输出gorm标签
|
|
|
|
|
// is_db_tag. 是否输出gorm标签
|
|
|
|
|
if config.GetIsDbTag() {
|
|
|
|
|
// not simple output. 默认只输出gorm主键和字段标签
|
|
|
|
|
if !config.GetSimple() {
|
|
|
|
|
for _, v1 := range v.Index {
|
|
|
|
|
switch v1.Key {
|
|
|
|
@ -147,10 +149,22 @@ func (m *_Model) genTableElement(cols []ColumnsInfo) (el []genstruct.GenElement)
|
|
|
|
|
tmp.AddTag(_tagGorm, getUninStr("uniqueIndex", ":", v1.KeyName))
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
for _, v1 := range v.Index {
|
|
|
|
|
switch v1.Key {
|
|
|
|
|
// case ColumnsKeyDefault:
|
|
|
|
|
case ColumnsKeyPrimary: // primary key.主键
|
|
|
|
|
tmp.AddTag(_tagGorm, "primaryKey")
|
|
|
|
|
isPK = true
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if len(v.Name) > 0 {
|
|
|
|
|
// is_db_tag. 是否输出gorm标签
|
|
|
|
|
if config.GetIsDbTag() {
|
|
|
|
|
// not simple output
|
|
|
|
|
if !config.GetSimple() {
|
|
|
|
|
tmp.AddTag(_tagGorm, "column:"+v.Name)
|
|
|
|
@ -162,6 +176,9 @@ func (m *_Model) genTableElement(cols []ColumnsInfo) (el []genstruct.GenElement)
|
|
|
|
|
if len(v.Gormt) > 0 {
|
|
|
|
|
tmp.AddTag(_tagGorm, v.Gormt)
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
tmp.AddTag(_tagGorm, "column:"+v.Name)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// json tag
|
|
|
|
|