fix(makecode): 树查询 showself 仅在 showall 时生效

避免 parent_id 懒加载把节点自身混入子级导致无限嵌套,并补充 department 回归用例与文档。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-07-22 08:58:46 +08:00
parent 412f08a048
commit b254606003
5 changed files with 151 additions and 2 deletions
+4 -2
View File
@@ -1244,8 +1244,10 @@ func (that *MakeCode) Search(table string, userData Map, data Map, req *http.Req
} else {
where["parent_id"] = reqValue
}
//是否展示自己
if req.FormValue("showself") == "1" {
//是否展示自己:仅在 showall=1(选中节点及全部子孙)场景生效;
//普通子级懒加载(仅 parent_id=X)不得把 id=X 的行本身混入结果,
//否则前端树把节点当成自己的子级,造成无限嵌套
if req.FormValue("showself") == "1" && req.FormValue("showall") == "1" {
if len(where) == 0 {
data["OR"] = Map{"id": reqValue}
} else {