summaryrefslogtreecommitdiff
path: root/app/api/swp/upload/route.ts
diff options
context:
space:
mode:
Diffstat (limited to 'app/api/swp/upload/route.ts')
-rw-r--r--app/api/swp/upload/route.ts24
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 동기화는 불필요