diff options
| author | joonhoekim <26rote@gmail.com> | 2025-11-11 15:47:29 +0900 |
|---|---|---|
| committer | joonhoekim <26rote@gmail.com> | 2025-11-11 15:47:29 +0900 |
| commit | e207799f1c1a058853f9fa6ad151dc61317a93c1 (patch) | |
| tree | ceb589e18d871fc968732cad6bfd0863c13c94da /app | |
| parent | cc023040c83dc663659ab89a99c133e357ec5a5a (diff) | |
(김준회) swp: SBOX 저장 API 호출시 crter를 user id로 보내주도록 변경 (조민정프로 합의완료)
Diffstat (limited to 'app')
| -rw-r--r-- | app/api/swp/upload/route.ts | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/app/api/swp/upload/route.ts b/app/api/swp/upload/route.ts index 986862b2..7be77981 100644 --- a/app/api/swp/upload/route.ts +++ b/app/api/swp/upload/route.ts @@ -1,6 +1,8 @@ import { NextRequest, NextResponse } from "next/server"; import * as fs from "fs/promises"; import * as path from "path"; +import { getServerSession } from "next-auth"; +import { authOptions } from "@/app/api/auth/[...nextauth]/route"; import { fetchGetVDRDocumentList, fetchGetExternalInboxList } from "@/lib/swp/api-client"; import { debugLog, debugError, debugSuccess } from "@/lib/debug-utils"; @@ -134,11 +136,14 @@ async function getCpyCdForVendor(projNo: string, vndrCd: string): Promise<string /** * SaveInBoxList API 호출 */ -async function callSaveInBoxList(fileInfos: InBoxFileInfo[]): Promise<void> { +async function callSaveInBoxList(fileInfos: InBoxFileInfo[], crter: string): Promise<void> { const ddcUrl = process.env.DDC_BASE_URL || "http://60.100.99.217/DDC/Services/WebService.svc"; const url = `${ddcUrl}/SaveInBoxList`; - const request = { externalInboxLists: fileInfos }; + const request = { + externalInboxLists: fileInfos, + crter: crter + }; console.log("[callSaveInBoxList] 요청:", JSON.stringify(request, null, 2)); @@ -195,6 +200,19 @@ async function callSaveInBoxList(fileInfos: InBoxFileInfo[]): Promise<void> { */ export async function POST(request: NextRequest) { try { + // 세션에서 사용자 ID 가져오기 + const session = await getServerSession(authOptions); + + if (!session?.user?.id) { + return NextResponse.json( + { success: false, message: "인증되지 않은 사용자입니다." }, + { status: 401 } + ); + } + + const crter = String(session.user.id); // 사용자 ID를 문자열로 변환 + console.log(`[upload] 사용자 ID (crter): ${crter}`); + const formData = await request.formData(); const projNo = formData.get("projNo") as string; @@ -347,7 +365,7 @@ export async function POST(request: NextRequest) { // SaveInBoxList API 호출 if (inBoxFileInfos.length > 0) { console.log(`[upload] SaveInBoxList API 호출: ${inBoxFileInfos.length}개 파일`); - await callSaveInBoxList(inBoxFileInfos); + await callSaveInBoxList(inBoxFileInfos, crter); } // ⚠️ Full API 방식으로 전환했으므로 로컬 DB 동기화는 불필요 |
