feat: 좋아요·댓글·SNS 업로드를 콘텐츠 종류 공용으로 통합

This commit is contained in:
skkim committed 2026-08-11 11:03:03 +09:00
1 parent ed1ba71bfe
commit fb8febe462
7 files changed
+318 -109

No files matched your search

+16 -4
View File
@@ -9,7 +9,9 @@ Comment API Router
- DELETE /comment/{comment_id}: 본인 댓글 소프트 삭제 (로그인 필수)
"""
from fastapi import APIRouter, Depends
from typing import Literal
from fastapi import APIRouter, Depends, Query
from sqlalchemy.ext.asyncio import AsyncSession
from app.comment.schemas.comment_schema import (
@@ -60,12 +62,16 @@ router = APIRouter(prefix="/comment", tags=["Comment"])
async def post_comment(
video_id: int,
body: CommentCreateRequest,
type: Literal["video", "ssul"] = Query(
default="video",
description="콘텐츠 종류. video.id 와 ssul_content.id 가 겹치므로 반드시 함께 보낼 것",
),
current_user: User = Depends(get_current_user),
session: AsyncSession = Depends(get_session),
) -> CommentCreateResponse:
logger.info(
f"[post_comment] START - video_id: {video_id}, user: {current_user.user_uuid}, "
f"parent_id: {body.parent_id}"
f"[post_comment] START - type: {type}, id: {video_id}, "
f"user: {current_user.user_uuid}, parent_id: {body.parent_id}"
)
comment = await create_comment(
session=session,
@@ -74,6 +80,7 @@ async def post_comment(
nickname=body.nickname,
content=body.content,
parent_id=body.parent_id,
content_type=type,
)
logger.info(f"[post_comment] SUCCESS - comment_id: {comment.id}")
return CommentCreateResponse(
@@ -112,12 +119,16 @@ async def post_comment(
)
async def get_comments(
video_id: int,
type: Literal["video", "ssul"] = Query(
default="video",
description="콘텐츠 종류. video.id 와 ssul_content.id 가 겹치므로 반드시 함께 보낼 것",
),
current_user: User | None = Depends(get_current_user_optional),
session: AsyncSession = Depends(get_session),
pagination: PaginationParams = Depends(get_pagination_params),
) -> PaginatedResponse[CommentItem]:
logger.info(
f"[get_comments] START - video_id: {video_id}, "
f"[get_comments] START - type: {type}, id: {video_id}, "
f"page: {pagination.page}, page_size: {pagination.page_size}"
)
current_user_uuid = current_user.user_uuid if current_user else None
@@ -127,6 +138,7 @@ async def get_comments(
page=pagination.page,
page_size=pagination.page_size,
current_user_uuid=current_user_uuid,
content_type=type,
)
logger.info(f"[get_comments] SUCCESS - total: {result.total}, items: {len(result.items)}")
return result