Files
family-service/routers/comment.py
2026-09-06 16:07:00 +08:00

24 lines
900 B
Python

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)