Fix: PDF 매칭 저장 기능 수정

- 백엔드 문서 업데이트 API에서 DocumentResponse 생성자 수정
- original_filename 필드 추가로 PDF 매칭 정보 제대로 반환
- uploader 필드 null 체크 추가
- 프론트엔드 저장 과정에 상세 디버깅 로그 추가
- PDF 매칭 정보와 순서 저장 과정 로그 추가
This commit is contained in:
Hyungi Ahn
2025-09-03 18:10:42 +09:00
parent b5602cbf44
commit 8f12eb4f76
2 changed files with 15 additions and 5 deletions

View File

@@ -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
)

View File

@@ -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;