AI 托管账号支持筛选未托管

筛选只有「仅已托管」一个选项,想找还没开启的账号只能翻页。补上
managed=0:未托管既包括从未绑定的账号,也包括绑定后被关闭的账号,
运营要开启的正是这两类,所以放在一起。

测试覆盖三种状态,并断言两个筛选相加等于全部、没有重复计数。

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
Your Name
2026-09-04 11:34:39 +08:00
co-authored by Claude Opus 5
parent 151834caac
commit b42743c882
2 changed files with 67 additions and 1 deletions
+7 -1
View File
@@ -33,8 +33,14 @@ func (a *App) adminAIAgents(w http.ResponseWriter, r *http.Request) {
fail(w, http.StatusBadRequest, 20001, err.Error())
return
}
if strings.TrimSpace(r.URL.Query().Get("managed")) == "1" {
// "0" is not the absence of a filter here: an account is unmanaged both when
// it has no binding at all and when its binding is switched off, and the
// operator looking for accounts to turn on wants to see both.
switch strings.TrimSpace(r.URL.Query().Get("managed")) {
case "1":
where += " AND g.user_id IS NOT NULL AND g.enabled=1"
case "0":
where += " AND (g.user_id IS NULL OR g.enabled=0)"
}
// Same keyword shape as the user list: nickname or 星遇号.
if keyword := strings.TrimSpace(r.URL.Query().Get("keyword")); keyword != "" {