fix: Stats接口用户认证检查

This commit is contained in:
甲辰生产 2026-04-08 14:29:08 +08:00
parent bb30f0e711
commit 2a8dea6acf
1 changed files with 5 additions and 2 deletions

View File

@ -284,7 +284,10 @@ def get_stats(
"""获取藏品统计 - 使用数据库聚合查询优化性能""" """获取藏品统计 - 使用数据库聚合查询优化性能"""
from sqlalchemy import func, case from sqlalchemy import func, case
# 基础查询条件 # 基础查询条件 - 检查用户是否登录
if current_user is None or not hasattr(current_user, 'role'):
base_filter = False # 未登录用户不能查看任何藏品
else:
base_filter = True if current_user.role == "admin" else 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
# 总数 # 总数