nomadro/apps/api/services/ebook_svc/routers/audience_admin.py
Eric 4ad87fd4ab Ship pending portal, admin, miniprogram, and ebook business updates.
Refresh audience/admin UX, ntfy/track, social paths, and replace ebook chapters with the expanded catalog; keep local SQLite and one-off probe scripts out of tree.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-11-26 13:40:46 +08:00

41 lines
1.3 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

"""受众分轨 — 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
homeVariant: Literal["portal", "social", ""] | 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)