feat:完善项目信息

This commit is contained in:
henry
2022-01-04 11:59:58 +08:00
parent c3da1ebc51
commit e29371da3e
20 changed files with 357 additions and 62 deletions

View File

@ -29,3 +29,56 @@ func TestArrayStrings(t *testing.T) {
t.Log(b)
t.Log(reflect.TypeOf(b).String())
}
type Tree struct {
ID uint64 `json:"id"`
Checked bool `json:"checked"`
Children []*Tree `json:"children"`
}
func show(src []*Tree, parent *Tree) {
for _, v := range src {
if !v.Checked && parent != nil {
parent.Checked = false
}
if len(v.Children) > 0 {
show(v.Children, v)
}
}
}
func input(src []*Tree, out map[uint64]uint64) {
for _, v := range src {
out[v.ID] = v.ID
if len(v.Children) > 0 {
input(v.Children, out)
}
}
}
func TestInArray(t *testing.T) {
src := []*Tree{
&Tree{
ID: 1,
Checked: false,
Children: []*Tree{
&Tree{
ID: 2,
Checked: true,
Children: nil,
},
&Tree{
ID: 3,
Checked: false,
Children: nil,
},
},
},
}
out := make(map[uint64]uint64, 0)
input(src, out)
//show(out, nil)
t.Log(AnyToJSON(out))
}