From bf0c2cd73822612f47c329bfc83d4045312da60b Mon Sep 17 00:00:00 2001 From: yuanzhao <2206582181@qq.com> Date: Wed, 17 May 2023 16:39:11 +0800 Subject: [PATCH] =?UTF-8?q?add:=20=E5=88=86=E8=A1=A8=E4=BF=9D=E7=95=99?= =?UTF-8?q?=E6=95=B0=E5=AD=97=E6=9C=80=E5=A4=A7=E7=9A=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- console/commands/orm/mysql.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/console/commands/orm/mysql.go b/console/commands/orm/mysql.go index 62e68de..1ae2a45 100644 --- a/console/commands/orm/mysql.go +++ b/console/commands/orm/mysql.go @@ -473,21 +473,26 @@ func Filter(tableColumns map[string][]tableColumn) TableInfo { Columns: make(map[string][]tableColumn), Infos: make(map[string]TableInfos), } - + tableSort := make(map[string]int) for tableName, columns := range tableColumns { arr := strings.Split(tableName, "_") arrLen := len(arr) if arrLen > 1 { str := arr[arrLen-1] - _, err := strconv.Atoi(str) + tn, err := strconv.Atoi(str) if err == nil { tableName = strings.ReplaceAll(tableName, "_"+str, "") info.Infos[tableName] = TableInfos{ "sub": "true", // 分表 } + // 保留数字最大的 + n, ok := tableSort[tableName] + if ok && n > tn { + continue + } + tableSort[tableName] = tn } } - info.Columns[tableName] = columns } return info