feat(web): 播报板搜索支持按节点 id 筛选
搜索框在内容/来源之外,新增节点 id 匹配:纯数字或 UI 展示的「#41」形式 都会精确命中该节点。服务端 NodesPage 在 payload/origin ILIKE 的 OR 组里 追加 id 精确匹配;mock 同步;补 NodesPage id 搜索测试。
This commit is contained in:
1 parent
c6c5329a18
commit
e2ada7e494
4 files changed
+65
-3
No files matched your search
+10
-1
@@ -7,6 +7,7 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"sort"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
@@ -828,7 +829,15 @@ func (s *ExplorationStore) NodesPage(f NodeFilter, page, size int) ([]*Node, int
|
||||
if q := strings.TrimSpace(f.Query); q != "" {
|
||||
args = append(args, "%"+q+"%")
|
||||
mark := "$" + fmt.Sprint(len(args))
|
||||
conds = append(conds, "(payload::text ILIKE "+mark+" OR COALESCE(origin,'') ILIKE "+mark+")")
|
||||
ors := []string{"payload::text ILIKE " + mark, "COALESCE(origin,'') ILIKE " + mark}
|
||||
// 纯数字(或 UI 里带 # 前缀的形式,如「#41」)当作节点 id 精确匹配,方便直接定位某个节点。
|
||||
if idStr := strings.TrimPrefix(q, "#"); idStr != "" {
|
||||
if id, err := strconv.ParseInt(idStr, 10, 64); err == nil {
|
||||
args = append(args, id)
|
||||
ors = append(ors, "id = $"+fmt.Sprint(len(args)))
|
||||
}
|
||||
}
|
||||
conds = append(conds, "("+strings.Join(ors, " OR ")+")")
|
||||
}
|
||||
where := " WHERE " + strings.Join(conds, " AND ")
|
||||
|
||||
|
||||
Reference in new issue
Block a user