admin share

This commit is contained in:
朱潮 2026-02-01 18:40:58 +08:00
parent 2ee0bca96d
commit 4a96f98a40

View File

@ -2257,6 +2257,8 @@ async def search_users(
async with pool.connection() as conn:
async with conn.cursor() as cursor:
# 动态构建查询:如果有 user_id 则排除当前用户
if user_id:
await cursor.execute("""
SELECT id, username, email
FROM agent_user
@ -2266,6 +2268,15 @@ async def search_users(
ORDER BY username
LIMIT 20
""", (f"%{q}%", f"%{q}%", user_id))
else:
await cursor.execute("""
SELECT id, username, email
FROM agent_user
WHERE is_active = TRUE
AND (username ILIKE %s OR email ILIKE %s)
ORDER BY username
LIMIT 20
""", (f"%{q}%", f"%{q}%"))
rows = await cursor.fetchall()
return [