admin share
This commit is contained in:
parent
2ee0bca96d
commit
4a96f98a40
@ -2257,15 +2257,26 @@ 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:
|
||||||
await cursor.execute("""
|
# 动态构建查询:如果有 user_id 则排除当前用户
|
||||||
SELECT id, username, email
|
if user_id:
|
||||||
FROM agent_user
|
await cursor.execute("""
|
||||||
WHERE is_active = TRUE
|
SELECT id, username, email
|
||||||
AND (username ILIKE %s OR email ILIKE %s)
|
FROM agent_user
|
||||||
AND id != %s
|
WHERE is_active = TRUE
|
||||||
ORDER BY username
|
AND (username ILIKE %s OR email ILIKE %s)
|
||||||
LIMIT 20
|
AND id != %s
|
||||||
""", (f"%{q}%", f"%{q}%", user_id))
|
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()
|
rows = await cursor.fetchall()
|
||||||
|
|
||||||
return [
|
return [
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user