diff options
| author | joonhoekim <26rote@gmail.com> | 2025-11-20 12:17:02 +0900 |
|---|---|---|
| committer | joonhoekim <26rote@gmail.com> | 2025-11-20 12:17:02 +0900 |
| commit | 55f5af3304df92bcec7effd5899780e512a0be77 (patch) | |
| tree | 3d81718d133e197fca8d1c77045a645030905682 /lib | |
| parent | ac70d9f5daacdf83f24e45e7834ad6d3325c3cbb (diff) | |
(김준회) dolce: 타입 오류 수정
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/vendor-document-list/dolce-upload-service.ts | 33 | ||||
| -rw-r--r-- | lib/vendor-document-list/sync-service.ts | 5 |
2 files changed, 30 insertions, 8 deletions
diff --git a/lib/vendor-document-list/dolce-upload-service.ts b/lib/vendor-document-list/dolce-upload-service.ts index 8c66f234..41b9c2fa 100644 --- a/lib/vendor-document-list/dolce-upload-service.ts +++ b/lib/vendor-document-list/dolce-upload-service.ts @@ -318,6 +318,13 @@ class DOLCEUploadService { } | null> { const { users, vendors } = await import("@/db/schema") + // userId를 숫자로 변환하고 유효성 검증 + const userIdNum = Number(userId) + if (isNaN(userIdNum) || userIdNum <= 0) { + console.error(`Invalid userId: ${userId} (converted to NaN or invalid number)`) + throw new Error(`Invalid user ID: ${userId}`) + } + const [result] = await db .select({ userId: users.id, @@ -327,7 +334,7 @@ class DOLCEUploadService { }) .from(users) .innerJoin(vendors, eq(users.companyId, vendors.id)) - .where(eq(users.id, Number(userId))) + .where(eq(users.id, userIdNum)) .limit(1) if (!result) { @@ -446,10 +453,14 @@ class DOLCEUploadService { .from(documentAttachments) .where(eq(documentAttachments.revisionId, revision.id)) - revisionsWithAttachments.push({ + // serialNo를 숫자로 변환하여 RevisionWithAttachments 타입에 맞춤 + const convertedRevision: RevisionWithAttachments = { ...revision, + serialNo: typeof revision.serialNo === 'string' ? Number(revision.serialNo) : revision.serialNo, attachments - }) + } + + revisionsWithAttachments.push(convertedRevision) } return revisionsWithAttachments @@ -646,9 +657,15 @@ class DOLCEUploadService { try { const endpoint = `${this.BASE_URL}/Services/VDCSWebService.svc/DetailDwgReceiptMgmtEdit` + // UserID를 숫자로 변환하고 유효성 검증 + const userIdNum = Number(userId) + if (isNaN(userIdNum) || userIdNum <= 0) { + throw new Error(`Invalid UserID for DOLCE API: ${userId} (must be a positive integer)`) + } + const requestBody = { DwgList: dwgList, - UserID: userId, + UserID: userIdNum, // 정수형으로 변환 UserNM: userName, VENDORCODE: vendorCode, EMAIL: email @@ -691,9 +708,15 @@ class DOLCEUploadService { try { const endpoint = `${this.BASE_URL}/Services/VDCSWebService.svc/MatchBatchFileDwgEdit` + // UserID를 숫자로 변환하고 유효성 검증 + const userIdNum = Number(userId) + if (isNaN(userIdNum) || userIdNum <= 0) { + throw new Error(`Invalid UserID for DOLCE API: ${userId} (must be a positive integer)`) + } + const requestBody = { mappingSaveLists: mappingList, - UserID: userId + UserID: userIdNum // 정수형으로 변환 } console.log('Uploading file mapping to DOLCE:', JSON.stringify(requestBody, null, 2)) diff --git a/lib/vendor-document-list/sync-service.ts b/lib/vendor-document-list/sync-service.ts index c3ddfcca..64777ce9 100644 --- a/lib/vendor-document-list/sync-service.ts +++ b/lib/vendor-document-list/sync-service.ts @@ -346,12 +346,11 @@ class SyncService { } } - // DOLCE 업로드 실행 - 사용자 정보 전달 + // DOLCE 업로드 실행 - 사용자 ID 전달 const uploadResult = await dolceUploadService.uploadToDoLCE( projectId, revisionIds, - session.user.email || 'system_user', // 사용자 email - session.user.name || 'System Upload' // 사용자 name + String(session.user.id) // 사용자 ID (문자열로 변환) ) endpointResults['dolce_upload'] = uploadResult |
