diff --git a/code/makecode.go b/code/makecode.go index 6aea9fe..bf41794 100644 --- a/code/makecode.go +++ b/code/makecode.go @@ -986,12 +986,34 @@ func (that *MakeCode) Search(table string, userData Map, req *http.Request, db * } //树节点模式搜索 if searchItemName == "parent_id" { + if parent_idsStr != "" { + + where := Map{} + + for _, v := range reqValue { + if len(where) == 0 { + where[parent_idsStr] = "," + v + "," + continue + } + where = Map{"OR": where, parent_idsStr: "," + v + ","} + } + //用户 + if userData[searchItem.GetString("name")] != nil { + where = Map{"AND": Map{parent_idsStr: "," + ObjToStr(userData.GetCeilInt64(searchItem.GetString("name"))) + ",", "OR": where}} + } + r := db.Select(searchItem.GetString("link"), "id", where) + for _, v := range r { + reqValue = append(reqValue, v.GetString("id")) + } + + } + parentID := ObjToInt(req.FormValue("parent_id")) if parentID == 0 { parentID = userData.GetCeilInt(table + "_id") data["OR"] = Map{table + ".id": parentID, table + ".parent_id": nil} } else { - data[table+".parent_id"] = parentID + data[table+".parent_id"] = reqValue } continue }