cfeacb4bab
- 新表 platform_stat_display:每个指标可选 real/manual/random 三种 展示模式,含建表 + anchor_minutes 两个 alembic migration - 公开接口 GET /api/v1/platform/stats(无鉴权门面数字,登录前可读) - 运营后台 GET/PATCH /admin/api/dashboard-display 配置展示模式 - 配套 model/repository/schema,注册 router(app/main+admin/main), 导出 model,补 docs(api/database 索引及 3 篇详情) Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
39 lines
1.3 KiB
Python
39 lines
1.3 KiB
Python
"""admin 首页三统计展示配置 schemas。
|
|
|
|
倍率用千分比整数(1.000→1000);total_saved 的 manual_value / random_current 单位是分。
|
|
"""
|
|
from __future__ import annotations
|
|
|
|
from pydantic import BaseModel
|
|
|
|
|
|
class PlatformStatItemOut(BaseModel):
|
|
metric: str # help_users / total_compares / total_saved
|
|
label: str # 帮助用户 / 完成比价 / 累计节省
|
|
unit: str # 人 / 次 / 分
|
|
mode: str # real / manual / random
|
|
manual_value: int | None = None
|
|
random_mult_min: int
|
|
random_mult_max: int
|
|
random_tick_seconds: int
|
|
random_anchor_minutes: int
|
|
random_current: int | None = None
|
|
random_last_tick_at: str | None = None
|
|
real_value: int # 当前真实值(给运营对比参考)
|
|
updated_at: str | None = None
|
|
|
|
|
|
class PlatformStatUpdateRequest(BaseModel):
|
|
"""改某指标配置(均可选,只改传了的字段)。"""
|
|
|
|
mode: str | None = None
|
|
manual_value: int | None = None
|
|
random_mult_min: int | None = None
|
|
random_mult_max: int | None = None
|
|
random_tick_seconds: int | None = None
|
|
random_anchor_minutes: int | None = None
|
|
# 切 random 时的初始基数;不传则用当前真实值播种
|
|
random_initial: int | None = None
|
|
# 立即更新:不等更新钟点,保存后马上把展示值刷新一次(real 快照/manual 生效/random ×一档)
|
|
apply_now: bool = False
|