diff --git a/backend/app/routers/collections.py b/backend/app/routers/collections.py index 8479da6..cfad289 100644 --- a/backend/app/routers/collections.py +++ b/backend/app/routers/collections.py @@ -133,10 +133,6 @@ def get_collections( from sqlalchemy.orm import joinedload # 管理员默认查看全库,普通用户只看自己 - if current_user is None: - return {"error": "Unauthorized", "totalCount": 0} - - # 获取所有藏品 if current_user.role == "admin": # 联表查询获取用户名 query = db.query(Collection, User.f01_01_name.label('owner_name')).join( @@ -206,11 +202,7 @@ def get_collections( data_list = [] for item in data: # 处理联表查询结果 - if current_user is None: - return {"error": "Unauthorized", "totalCount": 0} - - # 获取所有藏品 - if current_user.role == "admin": + if current_user.role == "admin": collection_item, owner_name = item else: collection_item = item @@ -285,10 +277,6 @@ def get_stats( db: Session = Depends(get_db) ): """获取藏品统计""" - # 获取所有藏品 - if current_user is None: - return {"error": "Unauthorized", "totalCount": 0} - # 获取所有藏品 if current_user.role == "admin": all_collections = db.query(Collection).all()