"""Forum MVP API endpoints. Job ID: MTAD-IMPL-2025-11-18-CL""" from fastapi import APIRouter, Depends, HTTPException, status from sqlalchemy.orm import Session from app.database import get_db from app.models import ForumCategory, ForumThread, ForumPost router = APIRouter() @router.get("/categories") async def list_categories(db: Session = Depends(get_db)): """List all forum categories.""" categories = db.query(ForumCategory).order_by(ForumCategory.order).all() return {"items": categories} @router.get("/categories/{category_id}/threads") async def list_threads(category_id: str, skip: int = 0, limit: int = 10, db: Session = Depends(get_db)): """List threads in a category.""" threads = db.query(ForumThread).filter(ForumThread.category_id == category_id).offset(skip).limit(limit).all() return {"items": threads} @router.get("/threads/{thread_id}/posts") async def list_posts(thread_id: str, skip: int = 0, limit: int = 20, db: Session = Depends(get_db)): """List posts in a thread.""" posts = db.query(ForumPost).filter(ForumPost.thread_id == thread_id, ForumPost.deleted_at.is_(None)).offset(skip).limit(limit).all() return {"items": posts} @router.post("/categories") async def create_category(name: str, db: Session = Depends(get_db)): """Create forum category (admin only).""" return {"message": "Category creation not yet implemented"} @router.post("/threads") async def create_thread(category_id: str, title: str, db: Session = Depends(get_db)): """Create forum thread (requires authentication).""" return {"message": "Thread creation not yet implemented"} @router.post("/posts") async def create_post(thread_id: str, content: str, db: Session = Depends(get_db)): """Create forum post (requires authentication).""" return {"message": "Post creation not yet implemented"}