From 33cd7ebd6b8c92240551fd94b16888c6e7daa64c Mon Sep 17 00:00:00 2001 From: hoteas Date: Mon, 25 Jul 2022 05:44:38 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8A=80=E6=9C=AF=E6=80=A7=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- code/makecode.go | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) 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 }