forked from golang/hotime
加入树节点功能
This commit is contained in:
parent
9ea6082d04
commit
9aa836a72c
@ -546,7 +546,7 @@ func (that *MakeCode) Search(table string, req *http.Request, db *db.HoTimeDB) (
|
||||
v.GetString("link") + "_" + v.GetString("name") + "_" + v.GetString("value") + ","
|
||||
|
||||
leftJoin["[>]"+v.GetString("link")] =
|
||||
v.GetString("name") + "=" +
|
||||
table + "." + v.GetString("name") + "=" +
|
||||
v.GetString("link") + ".id"
|
||||
} else {
|
||||
reStr += table + "." + v.GetString("name") + ","
|
||||
@ -604,7 +604,7 @@ func (that *MakeCode) Search(table string, req *http.Request, db *db.HoTimeDB) (
|
||||
}
|
||||
|
||||
if searchItem.GetString("name") == "sort" {
|
||||
sort["ORDER"] = reqValue
|
||||
sort["ORDER"] = table + "." + reqValue
|
||||
}
|
||||
|
||||
continue
|
||||
@ -613,6 +613,17 @@ func (that *MakeCode) Search(table string, req *http.Request, db *db.HoTimeDB) (
|
||||
data[searchItemName] = reqValue
|
||||
}
|
||||
|
||||
//树节点模式搜索
|
||||
if req.Form["parent_id"] != nil {
|
||||
parentID := ObjToInt(req.FormValue("parent_id"))
|
||||
if parentID == 0 {
|
||||
data["OR"] = Map{table + ".parent_id[#]": 0, table + ".parent_id": nil}
|
||||
} else {
|
||||
data[table+".parent_id"] = parentID
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
where := Map{}
|
||||
|
||||
if len(keyword) == 1 {
|
||||
@ -621,7 +632,12 @@ func (that *MakeCode) Search(table string, req *http.Request, db *db.HoTimeDB) (
|
||||
}
|
||||
}
|
||||
if len(keyword) > 1 {
|
||||
data["OR"] = keyword
|
||||
if data["OR"] != nil {
|
||||
data = Map{"AND": data, "OR": keyword}
|
||||
} else {
|
||||
data["OR"] = keyword
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if len(daterange) == 1 {
|
||||
@ -631,7 +647,9 @@ func (that *MakeCode) Search(table string, req *http.Request, db *db.HoTimeDB) (
|
||||
}
|
||||
|
||||
if len(daterange) > 1 {
|
||||
data["AND"] = Map{"OR": daterange}
|
||||
if data["AND"] != nil {
|
||||
data = Map{"AND": Map{"AND": data, "OR": daterange}}
|
||||
}
|
||||
}
|
||||
|
||||
if len(data) > 1 {
|
||||
|
@ -649,7 +649,8 @@ func (that *HoTimeDB) varCond(k string, v interface{}) (string, []interface{}) {
|
||||
where := ""
|
||||
res := make([]interface{}, 0)
|
||||
length := len(k)
|
||||
if length > 4 {
|
||||
|
||||
if length > 0 && strings.Contains(k, "[") && k[length-1] == ']' {
|
||||
def := false
|
||||
|
||||
switch Substr(k, length-3, 3) {
|
||||
|
Loading…
Reference in New Issue
Block a user