admin share
This commit is contained in:
parent
2ee0bca96d
commit
4a96f98a40
@ -2257,6 +2257,8 @@ async def search_users(
|
|||||||
|
|
||||||
async with pool.connection() as conn:
|
async with pool.connection() as conn:
|
||||||
async with conn.cursor() as cursor:
|
async with conn.cursor() as cursor:
|
||||||
|
# 动态构建查询:如果有 user_id 则排除当前用户
|
||||||
|
if user_id:
|
||||||
await cursor.execute("""
|
await cursor.execute("""
|
||||||
SELECT id, username, email
|
SELECT id, username, email
|
||||||
FROM agent_user
|
FROM agent_user
|
||||||
@ -2266,6 +2268,15 @@ async def search_users(
|
|||||||
ORDER BY username
|
ORDER BY username
|
||||||
LIMIT 20
|
LIMIT 20
|
||||||
""", (f"%{q}%", f"%{q}%", user_id))
|
""", (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()
|
rows = await cursor.fetchall()
|
||||||
|
|
||||||
return [
|
return [
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user