完善中间件自动更新逻辑

This commit is contained in:
BBIT-Kai
2025-12-30 17:55:43 +08:00
parent 62e8ecb7d6
commit 3c1128b356
8 changed files with 74 additions and 26 deletions
+3
View File
@@ -78,6 +78,7 @@ def get_device_list_db_page(
d.is_active,
d.is_superuser,
d.dept_id,
d.type,
sd.name AS dept_name,
d.created_at
FROM iot_users d
@@ -99,6 +100,7 @@ def get_device_list_db_page(
is_active,
is_superuser,
dept_id,
type,
dept_name,
created_at,
) = r
@@ -111,6 +113,7 @@ def get_device_list_db_page(
"status": 1 if is_active else 0,
"is_superuser": 1 if is_superuser else 0,
"dept_id": dept_id,
"device_type": type,
"dept_name": dept_name,
"created_at": format_datetime(created_at),
}
+12 -2
View File
@@ -952,16 +952,26 @@ def get_dept_id_by_user_id(user_id: str) -> str:
return str(dept_id)
def get_dept_id_by_iot_user_name(user_id: UUID) -> str:
def get_dept_id_by_iot_user_name(user_id: str) -> str:
# 通过 iot_user_id 查找其所属的 dept_id
with pg_pool.getConn() as conn:
with conn.cursor() as cursor:
cursor.execute("SELECT dept_id FROM iot_users WHERE name = %s", (user_id,))
dept_id = cursor.fetchone()
dept_id = dept_id[0]
dept_id = str(dept_id[0])
return dept_id
def get_device_type_by_iot_user_name(user_id: str) -> str:
# 通过 iot_user_id 查找其所属的 type
with pg_pool.getConn() as conn:
with conn.cursor() as cursor:
cursor.execute("SELECT type FROM iot_users WHERE name = %s", (user_id,))
type = cursor.fetchone()
type = str(type[0])
return type
from typing import List