调整数据库表名,增加催青阶段分析演示模块

This commit is contained in:
BBIT-Kai
2026-01-04 16:06:13 +08:00
parent 209d087fa5
commit e2982b141d
16 changed files with 589 additions and 34 deletions
+11 -9
View File
@@ -446,7 +446,7 @@ def get_user_list_db_page(
with conn.cursor() as cursor:
# ---- 统计总数 ----
count_sql = f"SELECT COUNT(*) FROM users u {where_clause};"
count_sql = f"SELECT COUNT(*) FROM sys_users u {where_clause};"
cursor.execute(count_sql, params)
total = cursor.fetchone()[0]
@@ -461,7 +461,7 @@ def get_user_list_db_page(
u.dept_id,
d.name AS dept_name,
u.created_at
FROM users u
FROM sys_users u
LEFT JOIN sys_dept d ON u.dept_id = d.id
{where_clause}
ORDER BY u.created_at DESC
@@ -511,7 +511,9 @@ def get_user_list_db_page(
def db_user_name_exists(username: str) -> bool:
with pg_pool.getConn() as conn:
with conn.cursor() as cursor:
cursor.execute("SELECT COUNT(*) FROM users WHERE email = %s;", (username,))
cursor.execute(
"SELECT COUNT(*) FROM sys_users WHERE email = %s;", (username,)
)
return cursor.fetchone()[0] > 0
@@ -521,7 +523,7 @@ def insert_user(data: dict) -> str:
with conn.cursor() as cursor:
cursor.execute(
"""
INSERT INTO users (username, email, phone, is_active, dept_id, password_hash)
INSERT INTO sys_users (username, email, phone, is_active, dept_id, password_hash)
VALUES (%s, %s, %s, %s, %s, %s) RETURNING id;
""",
(
@@ -578,7 +580,7 @@ def patch_user_db(id: str, data: dict) -> int:
# 如果有需要更新的字段
if fields:
sql = f"UPDATE users SET {', '.join(fields)} WHERE id = %s"
sql = f"UPDATE sys_users SET {', '.join(fields)} WHERE id = %s"
params.append(id)
cursor.execute(sql, tuple(params))
@@ -603,7 +605,7 @@ def delete_user_db(id: str) -> int:
with pg_pool.getConn() as conn:
with conn.cursor() as cursor:
cursor.execute("DELETE FROM sys_user_role WHERE user_id=%s;", (id,))
cursor.execute("DELETE FROM users WHERE id=%s;", (id,))
cursor.execute("DELETE FROM sys_users WHERE id=%s;", (id,))
conn.commit()
return cursor.rowcount
@@ -882,7 +884,7 @@ def get_dept_ids_by_user_id(user_id: UUID) -> list:
# 第一步:通过 user_id 查找其所属的 dept_id
with pg_pool.getConn() as conn:
with conn.cursor() as cursor:
cursor.execute("SELECT dept_id FROM users WHERE id = %s", (user_id,))
cursor.execute("SELECT dept_id FROM sys_users WHERE id = %s", (user_id,))
dept_id = cursor.fetchone()
if not dept_id:
@@ -914,7 +916,7 @@ def get_dept_ids_by_user_id(user_id: UUID) -> list:
# 第一步:通过 user_id 查找其所属的 dept_id
with pg_pool.getConn() as conn:
with conn.cursor() as cursor:
cursor.execute("SELECT dept_id FROM users WHERE id = %s", (user_id,))
cursor.execute("SELECT dept_id FROM sys_users WHERE id = %s", (user_id,))
dept_id = cursor.fetchone()
if not dept_id:
@@ -946,7 +948,7 @@ def get_dept_id_by_user_id(user_id: str) -> str:
# 通过 user_id 查找其所属的 dept_id
with pg_pool.getConn() as conn:
with conn.cursor() as cursor:
cursor.execute("SELECT dept_id FROM users WHERE id = %s", (user_id,))
cursor.execute("SELECT dept_id FROM sys_users WHERE id = %s", (user_id,))
dept_id = cursor.fetchone()
dept_id = dept_id[0]
return str(dept_id)