nomadro/apps/api/services/ebook_svc/routers/social_blog_admin.py
Eric 499f2d3e26 Ship coffeechat scheduling, notify PB access, and social/admin UI polish for .com.
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>
2026-11-05 18:19:37 +08:00

44 lines
1.7 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 · Nomad Blog 运营(AdSense / 显隐 / 置顶)"""
from __future__ import annotations
from typing import Any
from fastapi import APIRouter, Depends
from pydantic import BaseModel, Field
from ebook_svc.core.security import require_admin
from ebook_svc.services import social_blog_ops as blog
router = APIRouter(prefix="/api/admin/social/blog", tags=["social-blog-admin"])
class BlogOpsPatch(BaseModel):
expectedVersion: int | None = Field(default=None, ge=0)
featuredSlug: str | None = Field(default=None, max_length=200)
hiddenSlugs: list[str] | None = Field(default=None, max_length=2000)
hideSlug: str | None = Field(default=None, max_length=200)
showSlug: str | None = Field(default=None, max_length=200)
note: str | None = Field(default=None, max_length=500)
heroLead: str | None = Field(default=None, max_length=400)
moduleEnabled: bool | None = None
adsenseEnabled: bool | None = None
adsenseClientId: str | None = Field(default=None, max_length=64, pattern=r"^(ca-pub-[0-9]+)?$")
adsensePublisherId: str | None = Field(default=None, max_length=64, pattern=r"^(pub-[0-9]+)?$")
adsenseSlotBlogMid: str | None = Field(default=None, max_length=32, pattern=r"^[0-9]*$")
adsenseSlotBlogEnd: str | None = Field(default=None, max_length=32, pattern=r"^[0-9]*$")
@router.get("/overview")
async def get_overview(_: str = Depends(require_admin)) -> dict[str, Any]:
return blog.overview()
@router.get("/posts")
async def get_posts(_: str = Depends(require_admin)) -> dict[str, Any]:
return blog.list_posts()
@router.patch("/ops")
async def patch_ops(body: BlogOpsPatch, _: str = Depends(require_admin)) -> dict[str, Any]:
return blog.patch_ops(body.model_dump(exclude_none=True))