| 1234567891011121314151617181920212223242526272829303132333435 |
- """请求 / 响应 Pydantic 模型。"""
- from typing import Any
- from pydantic import BaseModel, Field
- class SearchRequest(BaseModel):
- """搜索请求体(POST 用)。"""
- query: str = Field(..., min_length=1, description="搜索关键词")
- locale: str | None = Field(default=None, description="语言代码,留空使用默认")
- page: int = Field(default=1, ge=1)
- per_page: int = Field(default=25, ge=1, le=100)
- class SearchResponse(BaseModel):
- """统一响应信封。"""
- success: bool
- query: str
- count: int
- page: int
- per_page: int
- next_page: str | None = None
- sec_ids_used: list[int]
- results: list[dict[str, Any]]
- error: str | None = None
- class CacheStatus(BaseModel):
- """缓存状态。"""
- sec_ids_count: int
- last_updated_at: str | None
- next_refresh_at: str | None
|