From 88e734d6f7e59f1ea2b1c29e9dbbddaedbfba2af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=94=B2=E8=BE=B0=E7=94=9F=E4=BA=A7?= Date: Wed, 8 Apr 2026 09:06:48 +0800 Subject: [PATCH] =?UTF-8?q?v1.2.54=20-=20=E4=BF=AE=E5=A4=8Dstats=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E8=BF=87=E6=BB=A4=E6=9D=A1=E4=BB=B6bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/app/routers/collections.py | 9 ++------- frontend/index.html | 2 +- 2 files changed, 3 insertions(+), 8 deletions(-) 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 @@ - 甲辰收藏 v1.2.38 + 甲辰收藏 v1.2.53