From f4b1a770184e8647e0b3042a52a1bcc6f9cf00ce Mon Sep 17 00:00:00 2001 From: joonhoekim <26rote@gmail.com> Date: Wed, 12 Nov 2025 17:49:57 +0900 Subject: (김준회) SWP: 파일 업로드시 Stage 검증 추가, DOC_CLASS 관리 단순화 (코드 제거), DOC_CLASS 추가시 검증(A-Z0-9) 처리 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/swp/upload/route.ts | 54 +++++---------------------------------------- 1 file changed, 6 insertions(+), 48 deletions(-) (limited to 'app/api') diff --git a/app/api/swp/upload/route.ts b/app/api/swp/upload/route.ts index fcb2aa71..71c88cec 100644 --- a/app/api/swp/upload/route.ts +++ b/app/api/swp/upload/route.ts @@ -3,12 +3,11 @@ 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"; // API Route 설정 export const runtime = "nodejs"; -export const maxDuration = 300; // 5분 타임아웃 (대용량 파일 업로드 대응) +export const maxDuration = 3600; // 1시간 타임아웃 (대용량 파일 업로드 대응) interface InBoxFileInfo { CPY_CD: string; @@ -93,45 +92,6 @@ function generateTimestamp(): string { return `${year}${month}${day}${hours}${minutes}${seconds}`; } -/** - * CPY_CD 조회 (API 기반) - * GetVDRDocumentList API를 호출하여 해당 프로젝트/벤더의 CPY_CD를 조회 - */ -async function getCpyCdForVendor(projNo: string, vndrCd: string): Promise { - try { - console.log(`[getCpyCdForVendor] API 조회 시작: projNo=${projNo}, vndrCd=${vndrCd}`); - - // GetVDRDocumentList API 호출 (벤더 필터 적용) - const documents = await fetchGetVDRDocumentList({ - proj_no: projNo, - doc_gb: "V", - vndrCd: vndrCd, - }); - - console.log(`[getCpyCdForVendor] API 조회 완료: ${documents.length}개 문서`); - - if (!documents || documents.length === 0) { - throw new Error( - `프로젝트 ${projNo}에서 벤더 코드 ${vndrCd}에 할당된 문서가 없습니다.` - ); - } - - // 첫 번째 문서에서 CPY_CD 추출 - const cpyCd = documents[0].CPY_CD; - - if (!cpyCd) { - throw new Error( - `프로젝트 ${projNo}에서 벤더 코드 ${vndrCd}에 해당하는 회사 코드(CPY_CD)를 찾을 수 없습니다.` - ); - } - - console.log(`[getCpyCdForVendor] CPY_CD 확인: ${cpyCd}`); - return cpyCd; - } catch (error) { - console.error("[getCpyCdForVendor] 오류:", error); - throw error; - } -} /** * SaveInBoxList API 호출 @@ -225,10 +185,8 @@ export async function POST(request: NextRequest) { ); } - // CPY_CD 조회 - console.log(`[upload] CPY_CD 조회: projNo=${projNo}, vndrCd=${vndrCd}`); - const cpyCd = await getCpyCdForVendor(projNo, vndrCd); - console.log(`[upload] CPY_CD: ${cpyCd}`); + // vndrCd를 CPY_CD로 사용 + console.log(`[upload] vndrCd를 CPY_CD로 사용: ${vndrCd}`); const files = formData.getAll("files") as File[]; @@ -259,7 +217,7 @@ export async function POST(request: NextRequest) { console.log(`[upload] 파일명 파싱:`, parsed); // 네트워크 경로 생성 (timestamp를 경로에만 사용) - const networkPath = path.join(swpMountDir, projNo, cpyCd, uploadTimestamp, file.name); + const networkPath = path.join(swpMountDir, projNo, vndrCd, uploadTimestamp, file.name); // 파일 중복 체크 try { @@ -326,10 +284,10 @@ export async function POST(request: NextRequest) { }); // InBox 파일 정보 준비 (FLD_PATH에 업로드 timestamp 사용) - const fldPath = `\\${projNo}\\${cpyCd}\\\\${uploadTimestamp}`; + const fldPath = `\\${projNo}\\${vndrCd}\\\\${uploadTimestamp}`; inBoxFileInfos.push({ - CPY_CD: cpyCd, + CPY_CD: vndrCd, FILE_NM: file.name, OFDC_NO: null, PROJ_NO: projNo, -- cgit v1.2.3