From 46831f35014a115f94b70832f04017052f6d3a5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B0=A2=E5=B0=8F=E5=86=9B?= <346944475@qq.com> Date: Tue, 11 Aug 2020 18:17:13 +0800 Subject: [PATCH] add multi support --- data/view/model/model.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/data/view/model/model.go b/data/view/model/model.go index 04194f9..5e3466a 100644 --- a/data/view/model/model.go +++ b/data/view/model/model.go @@ -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) { + isMulti = true + var haveGomod bool for _, v := range m.info.TabList { if strings.EqualFold(v.Name, tableName) { @@ -174,7 +176,10 @@ func (m *_Model) getColumnsKeyMulti(tableName, col string) (isMulti bool, isFind switch v2.Key { case ColumnsKeyPrimary, ColumnsKeyUnique, ColumnsKeyUniqueIndex: // primary key unique key . 主键,唯一索引 { - return false, true, v.Notes + if !v2.Multi { + isMulti = false + break + } } // 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") { haveGomod = true notes = v.Notes