feat: 管理页面可查看用户藏品列表 - v1.1.22

This commit is contained in:
甲辰生产 2026-03-20 00:36:32 +08:00
parent 17fb08b487
commit 63718824a9
1 changed files with 28 additions and 0 deletions

View File

@ -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}") @router.get("/{collection_id}")
def get_collection( def get_collection(
collection_id: str, collection_id: str,