请教一个树平铺的问题
資深大佬 : cheng8984 8
type Tree struct {
Code string `json:”code”`
Parent string `json:”code”`
Child []*OrgTree `json:”child”`
}
Code string `json:”code”`
Parent string `json:”code”`
Child []*OrgTree `json:”child”`
}
type Flat struct {
Code string
Parent string
Lv0Code string
Lv1Code string
Lv2Code string
Lv3Code string
Lv4Code string
Lv5Code string
}
树的层级为 6,求平铺这颗树,得到一个[]Flat 切片,要求每一层的节点对应 Flat 里的 lv 层 Code,比如第二层的&Flat{Code:”test2″,Parent:”root”,lv0Code:”rootCode”,lv1Code:”test2″}
大佬有話說 (3)