Pay-then-profile join desk with live card, S3 upload fallback, hydration-safe drafts; document on test9 README. Co-authored-by: Cursor <cursoragent@cursor.com>
39 lines
1.1 KiB
Python
39 lines
1.1 KiB
Python
"""受众分轨 — admin.nomadro.com/audience(中文用户 / 国际)。"""
|
||
from __future__ import annotations
|
||
|
||
from typing import Any, Literal
|
||
|
||
from fastapi import APIRouter, Depends
|
||
from pydantic import BaseModel
|
||
|
||
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):
|
||
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)
|