diff options
| author | joonhoekim <26rote@gmail.com> | 2025-08-06 04:25:00 +0000 |
|---|---|---|
| committer | joonhoekim <26rote@gmail.com> | 2025-08-06 04:25:00 +0000 |
| commit | 0e68be98b4ad4691af77232cb0b02b17af825ba3 (patch) | |
| tree | 09dd9152c87a9c21343e6a1562c959a828e2b462 /lib/vendor-document-list/import-service.ts | |
| parent | de2ac5a2860bc25180971e7a11f852d9d44675b7 (diff) | |
(김준회) 문서/도서 리스트 및 제출(조선) 메뉴 디버깅(dolce)
- attachment revisionId 누락건 해결
- crypto 모듈에서 deprecated des-ecb 알고리즘 사용을 위한 추가 처리
- enhancedDocumentsView에 projectId 추가
- route에서 contractId -> projectId 사용하도록 변경
Diffstat (limited to 'lib/vendor-document-list/import-service.ts')
| -rw-r--r-- | lib/vendor-document-list/import-service.ts | 71 |
1 files changed, 67 insertions, 4 deletions
diff --git a/lib/vendor-document-list/import-service.ts b/lib/vendor-document-list/import-service.ts index 9e1016ea..f2c62d0b 100644 --- a/lib/vendor-document-list/import-service.ts +++ b/lib/vendor-document-list/import-service.ts @@ -471,7 +471,7 @@ class ImportService { */ private encryptDES(text: string): string { try { - const cipher = crypto.createCipher('des-ecb', this.DES_KEY) + const cipher = crypto.createCipheriv('des-ecb', this.DES_KEY, '') cipher.setAutoPadding(true) let encrypted = cipher.update(text, 'utf8', 'base64') encrypted += cipher.final('base64') @@ -498,7 +498,13 @@ class ImportService { const downloadUrl = `${process.env.DOLCE_DOWNLOAD_URL}?key=${encryptedKey}` ||`http://60.100.99.217:1111/Download.aspx?key=${encryptedKey}` - console.log(`Downloading file: ${fileName} with key: ${encryptedKey.substring(0, 20)}...`) + console.log(`🔗 DOLCE 다운로드 링크 생성:`) + console.log(` 파일명: ${fileName}`) + console.log(` FileId: ${fileId}`) + console.log(` UserId: ${userId}`) + console.log(` 암호화 키: ${encryptedKey}`) + console.log(` 다운로드 URL: ${downloadUrl}`) + console.log(`📥 DOLCE에서 파일 다운로드 시작: ${fileName}`) const response = await fetch(downloadUrl, { method: 'GET', @@ -508,16 +514,18 @@ class ImportService { }) if (!response.ok) { + console.error(`❌ DOLCE 다운로드 실패: HTTP ${response.status}`) + console.error(` URL: ${downloadUrl}`) throw new Error(`File download failed: HTTP ${response.status}`) } const buffer = Buffer.from(await response.arrayBuffer()) - console.log(`Downloaded ${buffer.length} bytes for ${fileName}`) + console.log(`✅ DOLCE에서 파일 다운로드 완료: ${fileName} (${buffer.length} bytes)`) return buffer } catch (error) { - console.error(`Failed to download file ${fileName}:`, error) + console.error(`❌ DOLCE 파일 다운로드 실패: ${fileName}`, error) throw error } } @@ -1524,6 +1532,61 @@ async getImportStatus( const enabled = process.env[`IMPORT_${upperSystem}_ENABLED`] return enabled === 'true' || enabled === '1' } + + /** + * DOLCE 업로드 확인 테스트 (업로드 후 파일이 DOLCE에 존재하는지 확인) + */ + async testDOLCEFileDownload( + fileId: string, + userId: string, + fileName: string + ): Promise<{ success: boolean; downloadUrl?: string; error?: string }> { + try { + // 암호화 문자열 생성: FileId↔UserId↔FileName + const encryptString = `${fileId}↔${userId}↔${fileName}` + const encryptedKey = this.encryptDES(encryptString) + + const downloadUrl = `${process.env.DOLCE_DOWNLOAD_URL}?key=${encryptedKey}` || `http://60.100.99.217:1111/Download.aspx?key=${encryptedKey}` + + console.log(`🧪 DOLCE 파일 다운로드 테스트:`) + console.log(` 파일명: ${fileName}`) + console.log(` FileId: ${fileId}`) + console.log(` UserId: ${userId}`) + console.log(` 암호화 키: ${encryptedKey}`) + console.log(` 다운로드 URL: ${downloadUrl}`) + + const response = await fetch(downloadUrl, { + method: 'GET', + headers: { + 'User-Agent': 'DOLCE-Integration-Service' + } + }) + + if (!response.ok) { + console.error(`❌ DOLCE 파일 다운로드 테스트 실패: HTTP ${response.status}`) + return { + success: false, + downloadUrl, + error: `HTTP ${response.status}` + } + } + + const buffer = Buffer.from(await response.arrayBuffer()) + console.log(`✅ DOLCE 파일 다운로드 테스트 성공: ${fileName} (${buffer.length} bytes)`) + + return { + success: true, + downloadUrl + } + + } catch (error) { + console.error(`❌ DOLCE 파일 다운로드 테스트 실패: ${fileName}`, error) + return { + success: false, + error: error instanceof Error ? error.message : 'Unknown error' + } + } + } } export const importService = new ImportService()
\ No newline at end of file |
