add multi support

master
谢小军 4 years ago
parent b709ca0259
commit 46831f3501

@ -165,6 +165,8 @@ func (m *_Model) genForeignKey(col ColumnsInfo) (fklist []genstruct.GenElement)
} }
func (m *_Model) getColumnsKeyMulti(tableName, col string) (isMulti bool, isFind bool, notes string) { func (m *_Model) getColumnsKeyMulti(tableName, col string) (isMulti bool, isFind bool, notes string) {
isMulti = true
var haveGomod bool var haveGomod bool
for _, v := range m.info.TabList { for _, v := range m.info.TabList {
if strings.EqualFold(v.Name, tableName) { if strings.EqualFold(v.Name, tableName) {
@ -174,7 +176,10 @@ func (m *_Model) getColumnsKeyMulti(tableName, col string) (isMulti bool, isFind
switch v2.Key { switch v2.Key {
case ColumnsKeyPrimary, ColumnsKeyUnique, ColumnsKeyUniqueIndex: // primary key unique key . 主键,唯一索引 case ColumnsKeyPrimary, ColumnsKeyUnique, ColumnsKeyUniqueIndex: // primary key unique key . 主键,唯一索引
{ {
return false, true, v.Notes if !v2.Multi {
isMulti = false
break
}
} }
// case ColumnsKeyIndex: // index key. 复合索引 // case ColumnsKeyIndex: // index key. 复合索引
// { // {
@ -182,7 +187,7 @@ func (m *_Model) getColumnsKeyMulti(tableName, col string) (isMulti bool, isFind
// } // }
} }
} }
return true, true, v.Notes return isMulti, true, v.Notes
} else if strings.EqualFold(v1.Type, "gorm.Model") { } else if strings.EqualFold(v1.Type, "gorm.Model") {
haveGomod = true haveGomod = true
notes = v.Notes notes = v.Notes

Loading…
Cancel
Save