Document the 2026-11-05 UI/UX upgrade and keep roster/live gates aligned with face-check and presence. Co-authored-by: Cursor <cursoragent@cursor.com>
40 lines
1.2 KiB
Python
40 lines
1.2 KiB
Python
"""受众分轨 — admin.nomadro.com/audience(中文用户 / 国际)。"""
|
||
from __future__ import annotations
|
||
|
||
from typing import Any, Literal
|
||
|
||
from fastapi import APIRouter, Depends
|
||
from pydantic import BaseModel, Field
|
||
|
||
from ebook_svc.core.security import require_admin
|
||
from ebook_svc.services.audience_config import read_audience_config, write_audience_config
|
||
|
||
router = APIRouter(prefix="/api/admin/audience", tags=["audience-admin"])
|
||
|
||
|
||
class LaneIn(BaseModel):
|
||
payEnabled: bool | None = None
|
||
socialFollow: bool | None = None
|
||
followChannel: Literal["wechat", "x", "none"] | None = None
|
||
vipCta: str | None = None
|
||
homeLead: str | None = None
|
||
note: str | None = None
|
||
|
||
|
||
class AudienceBody(BaseModel):
|
||
expectedVersion: int | None = Field(default=None, ge=0)
|
||
defaultLane: Literal["cn", "intl"] | None = None
|
||
cn: LaneIn | None = None
|
||
intl: LaneIn | None = None
|
||
|
||
|
||
@router.get("")
|
||
async def get_audience(_: str = Depends(require_admin)) -> dict[str, Any]:
|
||
return read_audience_config()
|
||
|
||
|
||
@router.put("")
|
||
async def put_audience(body: AudienceBody, _: str = Depends(require_admin)) -> dict[str, Any]:
|
||
patch = body.model_dump(exclude_none=True)
|
||
return write_audience_config(patch)
|