From 39e5d446043ca126ed86f1371aafa3be0040cb10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=94=B2=E8=BE=B0=E7=94=9F=E4=BA=A7?= Date: Sat, 11 Apr 2026 19:00:38 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0user=5Fid=E5=8F=82=E6=95=B0?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E6=88=91=E7=9A=84=E8=A1=8C=E6=83=85=E6=9D=83?= =?UTF-8?q?=E9=99=90=E8=BF=87=E6=BB=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/app/routers/information.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/backend/app/routers/information.py b/backend/app/routers/information.py index 633999b..8a4e17d 100644 --- a/backend/app/routers/information.py +++ b/backend/app/routers/information.py @@ -106,6 +106,7 @@ class InformationResponse(BaseModel): def get_information_list( info_type: Optional[str] = Query(None, description="类型: seek/deal/publish"), status: str = Query("active", description="状态: active/closed/expired"), + user_id: Optional[str] = Query(None, description="用户ID,用于获取该用户的行情"), page: int = Query(1, ge=1), page_size: int = Query(20, ge=1, le=500), current_user: Optional[User] = Depends(get_current_user), @@ -121,6 +122,10 @@ def get_information_list( if info_type: query = query.filter(Information.info_type == info_type) + # 如果传入了user_id,只返回该用户的行情 + if user_id: + query = query.filter(Information.user_id == user_id) + # 按创建时间倒序 query = query.order_by(Information.created_at.desc())