From 63718824a971d39a476001db8eab78c483945856 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=94=B2=E8=BE=B0=E7=94=9F=E4=BA=A7?= Date: Fri, 20 Mar 2026 00:36:32 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E7=AE=A1=E7=90=86=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=E5=8F=AF=E6=9F=A5=E7=9C=8B=E7=94=A8=E6=88=B7=E8=97=8F=E5=93=81?= =?UTF-8?q?=E5=88=97=E8=A1=A8=20-=20v1.1.22?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/app/routers/collections.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/backend/app/routers/collections.py b/backend/app/routers/collections.py index 4df0b5c..983ba1c 100644 --- a/backend/app/routers/collections.py +++ b/backend/app/routers/collections.py @@ -304,6 +304,34 @@ def get_stats( } +@router.get("/by-user/{user_id}") +def get_collections_by_user( + user_id: str, + current_user: User = Depends(get_current_user), + db: Session = Depends(get_db) +): + """获取指定用户的所有藏品(管理员专用)""" + if current_user.role != "admin": + raise HTTPException(status_code=403, detail="E00050: 仅管理员可访问") + + collections = db.query(Collection).filter( + Collection.f99_91_user_id == user_id + ).all() + + result = [] + for c in collections: + result.append({ + "f99_90_id": c.f99_90_id, + "f01_01_name": c.f01_01_name, + "f02_10_prefix_serial": c.f02_10_prefix_serial, + "f02_11_version": c.f02_11_version, + "f01_04_status": c.f01_04_status, + "f05_40_cost_price": c.f05_40_cost_price, + "f99_92_created_at": c.f99_92_created_at.isoformat() if c.f99_92_created_at else None + }) + + return result + @router.get("/{collection_id}") def get_collection( collection_id: str,