fix:修复博客评论接口
This commit is contained in:
@@ -304,22 +304,22 @@ def query_blog_comment(db: Session, blog_id: int) -> List[BlogCommentResponse]:
|
||||
return [BlogCommentResponse.from_orm(result) for result in results]
|
||||
|
||||
|
||||
def add_blog_comment(db: Session, request: Request, blog_comment: BlogCommentCreate) -> bool:
|
||||
blog = db.query(Blog).filter(Blog.id == blog_comment.blogId).first()
|
||||
def add_blog_comment(db: Session, request: Request, blog_id: int, blog_comment: BlogCommentCreate) -> bool:
|
||||
blog = db.query(Blog).filter(Blog.id == blog_id).first()
|
||||
if not blog:
|
||||
raise AppException("博客不存在")
|
||||
|
||||
if blog_comment.parentId != 0:
|
||||
parent_comment = db.query(BlogComment).filter(
|
||||
BlogComment.id == blog_comment.parentId,
|
||||
BlogComment.blog_id == blog_comment.blogId
|
||||
BlogComment.blog_id == blog_id
|
||||
).first()
|
||||
|
||||
if not parent_comment:
|
||||
raise AppException("父评论不存在")
|
||||
|
||||
db_comment = BlogComment(
|
||||
blog_id=blog_comment.blogId,
|
||||
blog_id=blog_id,
|
||||
parent_id=blog_comment.parentId,
|
||||
name=blog_comment.name,
|
||||
website=blog_comment.website,
|
||||
|
||||
Reference in New Issue
Block a user