diff options
Diffstat (limited to 'app/api/sync/import/route.ts')
| -rw-r--r-- | app/api/sync/import/route.ts | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/app/api/sync/import/route.ts b/app/api/sync/import/route.ts index f32a99e2..0a5df030 100644 --- a/app/api/sync/import/route.ts +++ b/app/api/sync/import/route.ts @@ -2,11 +2,13 @@ import { NextRequest, NextResponse } from "next/server" import { importService } from "@/lib/vendor-document-list/import-service" import { getServerSession } from "next-auth" import { authOptions } from "@/app/api/auth/[...nextauth]/route" +import { debugProcess, debugError, debugSuccess } from "@/lib/debug-utils" export async function POST(request: NextRequest) { try { const session = await getServerSession(authOptions) if (!session?.user?.id) { + debugError(`인증 실패`, { userId: session?.user?.id }) return NextResponse.json({ error: "Unauthorized" }, { status: 401 }) } @@ -14,20 +16,39 @@ export async function POST(request: NextRequest) { const { projectId, sourceSystem = 'DOLCE' } = body if (!projectId) { + debugError(`필수 파라미터 누락`, { projectId, sourceSystem }) return NextResponse.json( { error: 'Contract ID is required' }, { status: 400 } ) } + debugProcess(`DOLCE 가져오기 API 호출`, { + projectId, + sourceSystem, + userId: session.user.id + }) + const result = await importService.importFromExternalSystem( projectId, sourceSystem ) + debugSuccess(`DOLCE 가져오기 API 완료`, { + projectId, + success: result.success, + newCount: result.newCount, + updatedCount: result.updatedCount, + newAttachmentsCount: result.newAttachmentsCount, + downloadedFilesCount: result.downloadedFilesCount + }) + return NextResponse.json(result) } catch (error) { - console.error('Import failed:', error) + debugError(`DOLCE 가져오기 API 실패`, { + projectId: request.body ? 'unknown' : 'no body', + error + }) return NextResponse.json( { error: 'Import failed', |
