修复bug

This commit is contained in:
hoteas 2022-08-08 04:34:26 +08:00
parent c420e23edb
commit 524a892480
2 changed files with 39 additions and 4 deletions

View File

@ -836,9 +836,17 @@ func (that *MakeCode) Search(table string, userData Map, req *http.Request, db *
} }
} else { } else {
reStr += table + "." + v.GetString("name") + "," reStr += table + "." + v.GetString("name") + ","
} }
if v["name"] == "parent_id" && v.GetString("link") != "" {
leftJoin["[>]"+v.GetString("link")+" selfParent"] =
"selfParent.id=" +
v.GetString("link") + "." + v.GetString("name")
reStr += "selfParent." + v.GetString("value") + " AS " + v.GetString("link") + "_" + v.GetString("name") + "_" + v.GetString("value") + ","
}
//准备加入索引权限 //准备加入索引权限
if v.GetString("link") != "" && if v.GetString("link") != "" &&
userData != nil && userData != nil &&

View File

@ -634,15 +634,42 @@ func (that *HoTimeDB) Select(table string, qu ...interface{}) []Map {
v := testQuData[k] v := testQuData[k]
switch Substr(k, 0, 3) { switch Substr(k, 0, 3) {
case "[>]": case "[>]":
query += " LEFT JOIN `" + Substr(k, 3, len(k)-3) + "` ON " + v.(string) + " " func() {
table := Substr(k, 3, len(k)-3)
if !strings.Contains(table, " ") {
table = "`" + table + "`"
}
query += " LEFT JOIN " + table + " ON " + v.(string) + " "
}()
case "[<]": case "[<]":
query += " RIGHT JOIN `" + Substr(k, 3, len(k)-3) + "` ON " + v.(string) + " " func() {
table := Substr(k, 3, len(k)-3)
if !strings.Contains(table, " ") {
table = "`" + table + "`"
}
query += " RIGHT JOIN " + table + " ON " + v.(string) + " "
}()
} }
switch Substr(k, 0, 4) { switch Substr(k, 0, 4) {
case "[<>]": case "[<>]":
query += " FULL JOIN `" + Substr(k, 4, len(k)-4) + "` ON " + v.(string) + " " func() {
table := Substr(k, 4, len(k)-4)
if !strings.Contains(table, " ") {
table = "`" + table + "`"
}
query += " FULL JOIN " + table + " ON " + v.(string) + " "
}()
case "[><]": case "[><]":
query += " INNER JOIN `" + Substr(k, 4, len(k)-4) + "` ON " + v.(string) + " " func() {
table := Substr(k, 4, len(k)-4)
if !strings.Contains(table, " ") {
table = "`" + table + "`"
}
query += " INNER JOIN " + table + " ON " + v.(string) + " "
}()
} }
} }
} }