| 123456789101112131415161718192021222324252627282930313233343536373839404142 |
- """请求 / 响应 Pydantic 模型。
- 注意:所有响应都使用 app/response.py 中的 ApiResponse 信封包裹,
- 本文件仅定义 data 字段内的业务数据结构。
- """
- 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="en-us", description="语言代码,留空使用默认")
- page: int = Field(default=1, ge=1)
- per_page: int = Field(default=25, ge=1, le=100)
- class SearchData(BaseModel):
- """搜索响应数据(放入 ApiResponse.data 字段)。"""
- count: int
- page: int
- per_page: int
- is_next_page: bool
- results: list[dict[str, Any]]
- class CacheStatus(BaseModel):
- """缓存状态(放入 ApiResponse.data 字段)。"""
- sec_ids_count: int
- last_updated_at: str | None
- next_refresh_at: str | None
- class CacheRefreshResult(BaseModel):
- """手动刷新缓存的返回数据。"""
- sec_ids_count: int
- last_updated_at: str | None
|