From 8f12eb4f760927fdc4b86798b4b5d445e76f3876 Mon Sep 17 00:00:00 2001 From: Hyungi Ahn Date: Wed, 3 Sep 2025 18:10:42 +0900 Subject: [PATCH] =?UTF-8?q?Fix:=20PDF=20=EB=A7=A4=EC=B9=AD=20=EC=A0=80?= =?UTF-8?q?=EC=9E=A5=20=EA=B8=B0=EB=8A=A5=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 백엔드 문서 업데이트 API에서 DocumentResponse 생성자 수정 - original_filename 필드 추가로 PDF 매칭 정보 제대로 반환 - uploader 필드 null 체크 추가 - 프론트엔드 저장 과정에 상세 디버깅 로그 추가 - PDF 매칭 정보와 순서 저장 과정 로그 추가 --- backend/src/api/routes/documents.py | 5 +++-- frontend/static/js/book-editor.js | 15 ++++++++++++--- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/backend/src/api/routes/documents.py b/backend/src/api/routes/documents.py index 57521da..dc79d7d 100644 --- a/backend/src/api/routes/documents.py +++ b/backend/src/api/routes/documents.py @@ -802,13 +802,14 @@ async def update_document( created_at=document.created_at, updated_at=document.updated_at, document_date=document.document_date, - uploader_name=document.uploader.full_name or document.uploader.email, + uploader_name=document.uploader.full_name or document.uploader.email if document.uploader else "Unknown", tags=[tag.name for tag in document.tags], book_id=str(document.book.id) if document.book else None, book_title=document.book.title if document.book else None, book_author=document.book.author if document.book else None, sort_order=document.sort_order, - matched_pdf_id=str(document.matched_pdf_id) if document.matched_pdf_id else None + matched_pdf_id=str(document.matched_pdf_id) if document.matched_pdf_id else None, + original_filename=document.original_filename ) diff --git a/frontend/static/js/book-editor.js b/frontend/static/js/book-editor.js index 371d1eb..d54441e 100644 --- a/frontend/static/js/book-editor.js +++ b/frontend/static/js/book-editor.js @@ -206,24 +206,33 @@ window.bookEditorApp = () => ({ if (this.saving) return; this.saving = true; + console.log('💾 저장 시작...'); try { // 서적 정보 업데이트 + console.log('📚 서적 정보 업데이트 중...'); await window.api.updateBook(this.bookId, { title: this.bookInfo.title, author: this.bookInfo.author, description: this.bookInfo.description }); + console.log('✅ 서적 정보 업데이트 완료'); // 각 문서의 순서와 PDF 매칭 정보 업데이트 - const updatePromises = this.documents.map(doc => { + console.log('📄 문서 업데이트 시작...'); + const updatePromises = this.documents.map((doc, index) => { + console.log(`📄 문서 ${index + 1}/${this.documents.length}: ${doc.title}`); + console.log(` - sort_order: ${doc.sort_order}`); + console.log(` - matched_pdf_id: ${doc.matched_pdf_id || 'null'}`); + return window.api.updateDocument(doc.id, { sort_order: doc.sort_order, matched_pdf_id: doc.matched_pdf_id || null }); }); - await Promise.all(updatePromises); + const results = await Promise.all(updatePromises); + console.log('✅ 모든 문서 업데이트 완료:', results.length, '개'); console.log('✅ 모든 변경사항 저장 완료'); this.showNotification('변경사항이 저장되었습니다', 'success'); @@ -234,7 +243,7 @@ window.bookEditorApp = () => ({ }, 1500); } catch (error) { - console.error('저장 실패:', error); + console.error('❌ 저장 실패:', error); this.showNotification('저장에 실패했습니다: ' + error.message, 'error'); } finally { this.saving = false;