修复数值引用 BUG

This commit is contained in:
Max 2021-10-26 16:05:03 +08:00
parent e6ada51cf7
commit aa66dcab60

View file

@ -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
}
}
}