diff options
| author | joonhoekim <26rote@gmail.com> | 2025-08-06 07:02:24 +0000 |
|---|---|---|
| committer | joonhoekim <26rote@gmail.com> | 2025-08-06 07:02:24 +0000 |
| commit | d89d5daf4533397d6c1761777ad4cfa6892bbeea (patch) | |
| tree | 118eceb2b6185ca9fb52e765316ffd8f0f6f110a /app/api/sync | |
| parent | 0e68be98b4ad4691af77232cb0b02b17af825ba3 (diff) | |
(김준회) dolce import service 및 route 에 logging 추가
TODO 1. 이미 dolce에 업로드된 첨부파일들은 Category=TS로 오는 게 맞는지? 전부 TS로 수신됨. (dolce 측 확인 필요)
TODO 2. UseYN 은 'Y', 'N' 으로 오는 게 아니고 'True', 'False' 응답이 들어오고 있음.
Diffstat (limited to 'app/api/sync')
| -rw-r--r-- | app/api/sync/import/route.ts | 23 | ||||
| -rw-r--r-- | app/api/sync/import/status/route.ts | 26 |
2 files changed, 46 insertions, 3 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', diff --git a/app/api/sync/import/status/route.ts b/app/api/sync/import/status/route.ts index ddb202e4..ddebcd19 100644 --- a/app/api/sync/import/status/route.ts +++ b/app/api/sync/import/status/route.ts @@ -3,11 +3,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 GET(request: NextRequest) { try { const session = await getServerSession(authOptions) if (!session?.user?.id) { + debugError(`인증 실패`, { userId: session?.user?.id }) return NextResponse.json({ error: "Unauthorized" }, { status: 401 }) } @@ -16,20 +18,40 @@ export async function GET(request: NextRequest) { const sourceSystem = searchParams.get('sourceSystem') || 'DOLCE' if (!projectId) { + debugError(`필수 파라미터 누락`, { projectId, sourceSystem }) return NextResponse.json( - { error: 'Contract ID is required' }, + { error: 'Project ID is required' }, { status: 400 } ) } + debugProcess(`DOLCE 상태 조회 API 호출`, { + projectId, + sourceSystem, + userId: session.user.id + }) + const status = await importService.getImportStatus( Number(projectId), sourceSystem ) + debugSuccess(`DOLCE 상태 조회 완료`, { + projectId, + availableDocuments: status.availableDocuments, + newDocuments: status.newDocuments, + updatedDocuments: status.updatedDocuments, + availableAttachments: status.availableAttachments, + newAttachments: status.newAttachments, + importEnabled: status.importEnabled + }) + return NextResponse.json(status) } catch (error) { - console.error('Failed to get import status:', error) + debugError(`DOLCE 상태 조회 실패`, { + projectId: request.nextUrl.searchParams.get('projectId'), + error + }) return NextResponse.json( { error: 'Failed to get import status', |
