技术性调整

This commit is contained in:
hoteas 2022-07-25 05:44:38 +08:00
parent be02b3418d
commit 33cd7ebd6b

View File

@ -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
}