Fix: 링크 기능 디버깅 및 라우터 등록 수정

- document_links 라우터를 /api 경로에도 추가 등록 (링크 삭제 호환성)
- 노트 검색 실패 시 상세한 디버깅 로그 추가
- 존재하는 노트 목록 출력으로 문제 원인 파악
This commit is contained in:
Hyungi Ahn
2025-09-03 18:48:13 +09:00
parent d74cb070ca
commit d68bfd45b2
2 changed files with 14 additions and 1 deletions

View File

@@ -122,11 +122,22 @@ async def create_document_link(
target_note = None
if not target_doc:
# 문서에서 찾지 못하면 노트에서 찾기
print(f"🔍 문서에서 찾지 못함, 노트에서 검색: {link_data.target_document_id}")
from models.note_document import NoteDocument
result = await db.execute(select(NoteDocument).where(NoteDocument.id == link_data.target_document_id))
target_note = result.scalar_one_or_none()
if not target_note:
if target_note:
print(f"✅ 노트 찾음: {target_note.title}")
else:
print(f"❌ 노트도 찾지 못함: {link_data.target_document_id}")
# 디버깅: 실제 존재하는 노트들 확인
all_notes_result = await db.execute(select(NoteDocument).limit(5))
all_notes = all_notes_result.scalars().all()
print(f"🔍 존재하는 노트 예시 (최대 5개):")
for note in all_notes:
print(f" - ID: {note.id}, 제목: {note.title}")
raise HTTPException(
status_code=status.HTTP_404_NOT_FOUND,
detail="Target document or note not found"

View File

@@ -55,6 +55,8 @@ app.include_router(bookmarks.router, prefix="/api/bookmarks", tags=["책갈피"]
app.include_router(search.router, prefix="/api/search", tags=["검색"])
app.include_router(memo_trees.router, prefix="/api", tags=["트리 메모장"])
app.include_router(document_links.router, prefix="/api/documents", tags=["문서 링크"])
# 링크 삭제를 위한 추가 라우터 (document-links 경로 지원)
app.include_router(document_links.router, prefix="/api", tags=["문서 링크 (호환성)"])
app.include_router(note_documents.router, prefix="/api/note-documents", tags=["노트 문서"])
app.include_router(note_links.router, prefix="/api", tags=["노트 링크"])
app.include_router(notebooks.router, prefix="/api/notebooks", tags=["노트북"])