4b98d405d7
- app_config 加 get/set_app_version(独立 key,复用表不进 CONFIG_DEFS) - GET /api/v1/platform/app-version 公开读 + POST /internal/app-version 内部写(X-Internal-Secret) - tests/test_app_version.py 5 端到端测试 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
59 lines
2.2 KiB
Python
59 lines
2.2 KiB
Python
"""首页平台级展示数据 schemas(客户端首页门面数字)。"""
|
|
from __future__ import annotations
|
|
|
|
from pydantic import BaseModel, Field
|
|
|
|
|
|
class PlatformStatsOut(BaseModel):
|
|
"""首页三统计。total_saved 为分,客户端 ÷100 显示「元」。"""
|
|
|
|
help_users: int # 帮助用户(人)
|
|
total_compares: int # 完成比价(次)
|
|
total_saved_cents: int # 累计节省(分)
|
|
|
|
|
|
class SavingsFeedItem(BaseModel):
|
|
"""首页轮播一条。time 为北京时间 HH:MM:SS。"""
|
|
|
|
masked_user: str # 脱敏用户名,手机尾号(138****5678)或中文昵称(省钱**)混合风格
|
|
saved_amount_cents: int # 节省(分),客户端 ÷100 显示「x.xx 元」
|
|
time: str
|
|
|
|
|
|
class SavingsFeedOut(BaseModel):
|
|
items: list[SavingsFeedItem]
|
|
|
|
|
|
class AppFlagsOut(BaseModel):
|
|
"""客户端拉取的运营 feature flag(不鉴权,登录前也能拉)。客户端缓存后按需读。"""
|
|
|
|
comparing_ad_enabled: bool # 比价/领券期是否展示信息流广告(远程 kill-switch)
|
|
|
|
|
|
class AppVersionOut(BaseModel):
|
|
"""最新 App 版本信息(OTA 检查更新,不鉴权)。
|
|
|
|
客户端用 latest_version_code(整数,单调递增)与本机 versionCode 比较,**不要**用 version_name 字符串比。
|
|
latest_version_code=0 表示后台尚未配置任何版本 → 客户端一律视为"已是最新"。
|
|
"""
|
|
|
|
latest_version_code: int = 0 # 最新版 versionCode;0=未配置(无更新)
|
|
latest_version_name: str = "" # 展示用,如 "0.1.4"
|
|
apk_url: str = "" # 下载链接(发车产出的永久版本化链接)
|
|
update_note: str = "" # 更新说明,弹窗展示
|
|
min_supported_version_code: int = 0 # 本机低于此版本=强制更新;0=不强更(全可选)
|
|
apk_size_bytes: int = 0 # 包大小(字节),展示"约 xMB"
|
|
apk_sha256: str = "" # APK 完整性校验(客户端下载后比对,防损坏/劫持)
|
|
|
|
|
|
class AppVersionWriteIn(BaseModel):
|
|
"""内部写入最新版本(发布流程/应急,X-Internal-Secret 校验)。整组原子覆盖。"""
|
|
|
|
latest_version_code: int = Field(gt=0)
|
|
latest_version_name: str = Field(min_length=1)
|
|
apk_url: str = Field(min_length=1)
|
|
update_note: str = ""
|
|
min_supported_version_code: int = 0
|
|
apk_size_bytes: int = 0
|
|
apk_sha256: str = ""
|