Arag / app /admin /routers /links.py
AuthorBot
Refactor admin API into service and repository layers.
d6061d6
Raw
History Blame Contribute Delete
807 Bytes
"""admin/routers/links.py — Smart links (buy/preview URLs) routes.
Routes:
PUT /{slug}/smart-links/{book_id}
"""
from fastapi import APIRouter, Depends
from sqlalchemy.ext.asyncio import AsyncSession
from app.dependencies import get_db, get_current_author_scoped
from app.schemas.admin import SmartLinkUpdate
from app.services.link_service import LinkService
router = APIRouter()
@router.put("/{author_slug}/smart-links/{book_id}")
async def update_smart_link(
author_slug: str,
book_id: str,
body: SmartLinkUpdate,
current_user=Depends(get_current_author_scoped),
db: AsyncSession = Depends(get_db),
):
"""Update buy/preview URLs for a book. R-029/R-031: Validated via Pydantic schema."""
return await LinkService(db).update_smart_link(current_user.id, book_id, body)