|
|
package department
|
|
|
|
|
|
import (
|
|
|
"opp/protocol"
|
|
|
"testing"
|
|
|
)
|
|
|
|
|
|
func TestGetRootDepartment(t *testing.T) {
|
|
|
sub := []*protocol.Department{
|
|
|
{DepartmentId: 100, Name: "100"},
|
|
|
{DepartmentId: 200, Name: "200"},
|
|
|
}
|
|
|
Departments := []*protocol.Department{
|
|
|
{DepartmentId: 1, Name: "1", Departments: sub},
|
|
|
{DepartmentId: 2, Name: "2"},
|
|
|
{DepartmentId: 3, Name: "3", Departments: []*protocol.Department{{DepartmentId: 31, Name: "3-1", Departments: sub}, {DepartmentId: 32, Name: "3-2"}}},
|
|
|
{DepartmentId: 4, Name: "4", Departments: []*protocol.Department{{DepartmentId: 41, Name: "4-1"}, {DepartmentId: 42, Name: "4-2", Departments: sub}}},
|
|
|
}
|
|
|
|
|
|
var deps protocol.DepartmentsResponse = protocol.DepartmentsResponse{
|
|
|
Departments: []*protocol.Department{
|
|
|
{DepartmentId: 0, Name: "0", Departments: Departments},
|
|
|
},
|
|
|
}
|
|
|
depList := deps.GetRootDepartment()
|
|
|
for i := range depList {
|
|
|
d := depList[i]
|
|
|
t.Log("部门:", d.DepartmentId, deps.GetChildDepartmentIds(d, true))
|
|
|
}
|
|
|
} |
...
|
...
|
|