from fastapi import APIRouter, Depends from sqlalchemy.orm import Session from config.database import get_db from schemas.comment import CommentCreate, CommentUpdate from service import comment_service router = APIRouter(prefix="/comments", tags=["评论"]) @router.post("", response_model=bool, summary="发表评论") def create(comment_in: CommentCreate, db: Session = Depends(get_db)): return comment_service.create_comment(db, comment_in) @router.put("/{comment_id}", response_model=bool, summary="编辑评论") def update(comment_id: int, comment_in: CommentUpdate, db: Session = Depends(get_db)): return comment_service.update_comment(db, comment_id, comment_in) @router.delete("/{comment_id}", summary="删除评论") def delete(comment_id: int, current_user_id: int, db: Session = Depends(get_db)): return comment_service.delete_comment(db, comment_id, current_user_id)