添加user_id参数支持我的行情权限过滤
This commit is contained in:
parent
12c35e39db
commit
39e5d44604
|
|
@ -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())
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue