//解析查询结果;
func DealResultDb(this ITableVisitor, rslt []map[string]interface{}) (interface{}, int) {
result, n := ParseDbResult(this, rslt)
if n < 0 {
return nil, 0
}
list, ok := result.([]InvestSupervisorReq)
if !ok {
return nil, 0
}
stack := make([]InvestSupervisorReq, len(list))
flag := make([]int, len(list))
index:=0
Find(stack, list, 1, 0, flag,&index)
return stack, len(stack)
}
//组装结果集
func Find(res []InvestSupervisorReq, data []InvestSupervisorReq, level int, parent int, flag []int,index *int ) {
if level > 3 {
return
}
for i := 0; i < len(data); i++ {
if data[i].Head.SuperLevel == level && data[i].Head.SuperParent == parent && flag[i] == 0 {
flag[i] = 1
res[*index] =data[i]
*index++
Find(res, data, level+1, data[i].Head.SuperSelf, flag,index)
}
}
}
//奇怪的是不一旦进入debug模式第一次进入Find函数 index++之后 第二次进入Find函数就崩了
//下面是完整的报错信息
![exception1.JPG](https://static.studygolang.com/191224/bbafeef39c7193763870aab929fb9224.JPG)
![exception2.JPG](https://static.studygolang.com/191224/300627581496f242359cf86bced559c5.JPG)
![exception3.JPG](https://static.studygolang.com/191224/50447f929fba40a8468ef4c6b491956f.JPG)
![exception4.JPG](https://static.studygolang.com/191224/bed56190fada9f896b5a0f46facea901.JPG)
![exception5.JPG](https://static.studygolang.com/191224/f12b1eebe3b09ec9ee58545563eb2cc5.JPG)
![exception6.JPG](https://static.studygolang.com/191224/0e9eaef1d29718a3e693e2ce11b85cab.JPG)
有疑问加站长微信联系(非本文作者))