diff options
| author | dujinkim <dujin.kim@dtsolution.co.kr> | 2025-11-28 07:45:32 +0000 |
|---|---|---|
| committer | dujinkim <dujin.kim@dtsolution.co.kr> | 2025-11-28 07:45:32 +0000 |
| commit | 1eb7cf92d1d7711e5d62a750e7611dc6fd1a241d (patch) | |
| tree | b278c04fa755ed6375f20b5a179c60b033dd6d20 /lib/bidding/selection/actions.ts | |
| parent | 927b3d6cbfad6ce84ec1bff2faaace95e9586efd (diff) | |
(최겸) 구매 피드백 반영(입찰SAP 취소 개발 잔재)
Diffstat (limited to 'lib/bidding/selection/actions.ts')
| -rw-r--r-- | lib/bidding/selection/actions.ts | 43 |
1 files changed, 31 insertions, 12 deletions
diff --git a/lib/bidding/selection/actions.ts b/lib/bidding/selection/actions.ts index 0d2a8a75..f19fbe6d 100644 --- a/lib/bidding/selection/actions.ts +++ b/lib/bidding/selection/actions.ts @@ -17,6 +17,7 @@ import { vendorSelectionResults, biddingDocuments } from "@/db/schema" +import { saveFile } from '@/lib/file-stroage' interface SaveSelectionResultData { biddingId: number @@ -82,19 +83,37 @@ export async function saveSelectionResult(data: SaveSelectionResultData) { )) // 새 첨부파일 저장 - const documentInserts = data.attachments.map(file => ({ - biddingId: data.biddingId, - companyId: null, - documentType: 'selection_result' as const, - fileName: file.name, - originalFileName: file.name, - fileSize: file.size, - mimeType: file.type, - filePath: `/uploads/bidding/${data.biddingId}/selection/${file.name}`, // 실제 파일 저장 로직 필요 - uploadedBy: session.user.id - })) + const documentInserts: Array<typeof biddingDocuments.$inferInsert> = [] + + for (const file of data.attachments) { + // saveFile을 사용하여 파일 저장 + const saveResult = await saveFile({ + file, + directory: `bidding/${data.biddingId}/selection`, + originalName: file.name, + userId: session.user.id + }) - await db.insert(biddingDocuments).values(documentInserts) + if (saveResult.success && saveResult.publicPath) { + documentInserts.push({ + biddingId: data.biddingId, + companyId: null, + documentType: 'selection_result' as const, + fileName: saveResult.fileName || file.name, + originalFileName: saveResult.originalName || file.name, + fileSize: saveResult.fileSize || file.size, + mimeType: file.type, + filePath: saveResult.publicPath, + uploadedBy: session.user.id + }) + } else { + console.error('Failed to save file:', saveResult.error) + } + } + + if (documentInserts.length > 0) { + await db.insert(biddingDocuments).values(documentInserts) + } } revalidatePath(`/evcp/bid-selection/${data.biddingId}/detail`) |
