From aa66dcab6060a85c880fafa0495b6686a606b6df Mon Sep 17 00:00:00 2001 From: Max Date: Tue, 26 Oct 2021 16:05:03 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=95=B0=E5=80=BC=E5=BC=95?= =?UTF-8?q?=E7=94=A8=20BUG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- helper/array.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/helper/array.go b/helper/array.go index ac1a1006..19108113 100644 --- a/helper/array.go +++ b/helper/array.go @@ -157,8 +157,12 @@ func (opt ArrayTreeOption) Tree(records []map[string]interface{}) []map[string]i mapping := map[string]map[string]interface{}{} for i := range records { if key, has := records[i][opt.Key]; has { - records[i][opt.Children] = []map[string]interface{}{} - mapping[fmt.Sprintf("%v", key)] = records[i] + primary := fmt.Sprintf("%v", key) + mapping[primary] = map[string]interface{}{} + mapping[primary][opt.Children] = []map[string]interface{}{} + for k, v := range records[i] { + mapping[primary][k] = v + } } }