diff --git a/backend/app/routers/collections.py b/backend/app/routers/collections.py index 51b330e..b369641 100644 --- a/backend/app/routers/collections.py +++ b/backend/app/routers/collections.py @@ -284,13 +284,8 @@ def get_stats( """获取藏品统计 - 使用数据库聚合查询优化性能""" from sqlalchemy import case - # 基础查询条件 - if current_user.role == "admin": - base_filter = True - user_filter = True - else: - base_filter = Collection.f99_91_user_id == current_user.f99_90_id - user_filter = Collection.f99_91_user_id == current_user.f99_90_id + # 基础查询条件 - 管理员查看所有藏品,普通用户只看自己的 + base_filter = True if current_user.role == "admin" else Collection.f99_91_user_id == current_user.f99_90_id # 总数 - 使用 COUNT total_count = db.query(func.count(Collection.f99_90_id)).filter(base_filter).scalar() or 0 diff --git a/frontend/index.html b/frontend/index.html index 03c4351..2af0426 100644 --- a/frontend/index.html +++ b/frontend/index.html @@ -4,7 +4,7 @@ -