From 927b3d6cbfad6ce84ec1bff2faaace95e9586efd Mon Sep 17 00:00:00 2001 From: joonhoekim <26rote@gmail.com> Date: Fri, 28 Nov 2025 16:05:42 +0900 Subject: (김준회) dolce RegisterKind 코드 오류 수정 (APPP --> APPR-P), 업로드시 file max seq 처리 추가, 상세도면 추가시 RegisterSerialNo 최대값 + 1 으로 요청 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/dolce/upload-files/route.ts | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) (limited to 'app/api') diff --git a/app/api/dolce/upload-files/route.ts b/app/api/dolce/upload-files/route.ts index 898f9b2a..3d0a92f7 100644 --- a/app/api/dolce/upload-files/route.ts +++ b/app/api/dolce/upload-files/route.ts @@ -81,19 +81,33 @@ async function uploadFileToDolce( async function getExistingFileSeq(uploadId: string): Promise { try { const response = await fetch( - `${DOLCE_API_URL}/PorjectWebProxyService.ashx?service=FileInfoList`, + `${DOLCE_API_URL}/Services/VDCSWebService.svc/FileInfoList`, { method: "POST", headers: { "Content-Type": "application/json" }, - body: JSON.stringify({ uploadId }), + body: JSON.stringify({ uploadId: uploadId }), } ); if (response.ok) { const data = await response.json(); - const existingCount = data.FileInfoListResult?.length || 0; - console.log(`[Proxy] 기존 파일=${existingCount}개, 새 파일 시작 Seq=${existingCount + 1}`); - return existingCount + 1; + + let maxSeq = 0; + + // FileInfoListResult가 배열인지 확인하고 최대 FileSeq 탐색 + if (data.FileInfoListResult && Array.isArray(data.FileInfoListResult)) { + data.FileInfoListResult.forEach((item: any) => { + // FileSeq가 문자열로 오므로 숫자로 변환 (예: "6") + const seq = parseInt(item.FileSeq, 10); + if (!isNaN(seq) && seq > maxSeq) { + maxSeq = seq; + } + }); + } + + const nextSeq = maxSeq + 1; + console.log(`[Proxy] 기존 파일 최대 Seq=${maxSeq}, 새 파일 시작 Seq=${nextSeq}`); + return nextSeq; } else { console.warn(`[Proxy] FileInfoList 조회 실패, startSeq=1로 시작`); return 1; -- cgit v1.2.3