diff --git a/backend/src/api/routes/highlights.py b/backend/src/api/routes/highlights.py index 4386983..322eecb 100644 --- a/backend/src/api/routes/highlights.py +++ b/backend/src/api/routes/highlights.py @@ -173,9 +173,10 @@ async def get_document_highlights( detail="Not enough permissions to access this document" ) - # 사용자의 하이라이트만 조회 + # 사용자의 하이라이트만 조회 (연관된 메모도 함께 로드) result = await db.execute( select(Highlight) + .options(selectinload(Highlight.notes)) # 메모 관계 로드 .where( and_( Highlight.document_id == document_id, @@ -191,6 +192,17 @@ async def get_document_highlights( # 응답 데이터 변환 response_data = [] for highlight in highlights: + # 연관된 메모 정보 포함 (notes는 리스트이므로 첫 번째 메모 사용) + note_data = None + if highlight.notes and len(highlight.notes) > 0: + first_note = highlight.notes[0] # 첫 번째 메모 사용 + note_data = { + "id": str(first_note.id), + "content": first_note.content, + "created_at": first_note.created_at.isoformat(), + "updated_at": first_note.updated_at.isoformat() if first_note.updated_at else None + } + highlight_data = HighlightResponse( id=str(highlight.id), user_id=str(highlight.user_id), @@ -205,7 +217,7 @@ async def get_document_highlights( highlight_type=highlight.highlight_type, created_at=highlight.created_at, updated_at=highlight.updated_at, - note=None + note=note_data ) response_data.append(highlight_data) diff --git a/frontend/hierarchy.html b/frontend/hierarchy.html index 4b738c7..9eb22b7 100644 --- a/frontend/hierarchy.html +++ b/frontend/hierarchy.html @@ -380,7 +380,7 @@