diff options
| author | joonhoekim <26rote@gmail.com> | 2025-11-02 14:03:34 +0900 |
|---|---|---|
| committer | joonhoekim <26rote@gmail.com> | 2025-11-02 14:03:34 +0900 |
| commit | de4c6593f0cc91c6e0c1a4e2bf9581f11f4f5c98 (patch) | |
| tree | 8b3d88637309ac9fb67f79606d834364d784105b /lib/swp/vendor-actions.ts | |
| parent | fd5ff7a9eaea4baeacc3f4bec8254925d63bf255 (diff) | |
(김준회) SWP 리스트 관리 파트 오류 수정 및 요구사항 반영, 동적 상태 리스트 필터링 변경, null은 동기화 전(전송 전)으로 간주, 선택된 것만 보내도록 변경
Diffstat (limited to 'lib/swp/vendor-actions.ts')
| -rw-r--r-- | lib/swp/vendor-actions.ts | 100 |
1 files changed, 99 insertions, 1 deletions
diff --git a/lib/swp/vendor-actions.ts b/lib/swp/vendor-actions.ts index f65ed007..f87c41a8 100644 --- a/lib/swp/vendor-actions.ts +++ b/lib/swp/vendor-actions.ts @@ -1,5 +1,17 @@ "use server"; +/** + * SWP Vendor Actions + * + * 벤더 페이지(제출)에서 사용하는 서버 액션 모음입니다. + * - 다운로드 및 업로드는 서버액션의 데이터 직렬화 문제로, 별도의 API Route로 분리함 + * - 간단한 API 호출은 서버 액션으로 관리 + * + * 1. 파일 메타정보 업로드 + * 2. 파일 업로드 취소 + * + */ + import { getServerSession } from "next-auth"; import { authOptions } from "@/app/api/auth/[...nextauth]/route"; import db from "@/db/db"; @@ -145,7 +157,7 @@ export async function fetchVendorDocuments(projNo?: string): Promise<DocumentLis } catch (error) { debugError("문서 목록 조회 실패", error); console.error("[fetchVendorDocuments] 오류:", error); - throw new Error("문서 목록 조회 실패 [담당자에게 문의하세요]"); + throw new Error("문서 목록 조회 실패 [SWP 담당자에게 문의하세요]"); } } @@ -334,6 +346,92 @@ export async function fetchVendorSwpStats(projNo?: string) { } // ============================================================================ +// 벤더가 업로드한 파일 목록 조회 (Inbox) +// ============================================================================ + +export async function fetchVendorUploadedFiles(projNo: string) { + debugProcess("벤더 업로드 파일 목록 조회 시작", { projNo }); + + try { + const vendorInfo = await getVendorSessionInfo(); + + if (!vendorInfo) { + debugError("벤더 정보 없음 - 업로드 파일 조회 실패"); + throw new Error("벤더 정보를 찾을 수 없습니다."); + } + + if (!projNo) { + debugWarn("프로젝트 번호 없음"); + return []; + } + + debugLog("업로드 파일 목록 조회 시작", { + projNo, + vendorCode: vendorInfo.vendorCode + }); + + // api-client의 fetchGetExternalInboxList 사용 + const { fetchGetExternalInboxList } = await import("./api-client"); + const files = await fetchGetExternalInboxList({ + projNo, + vndrCd: vendorInfo.vendorCode, + }); + + debugSuccess("업로드 파일 목록 조회 성공", { count: files.length }); + return files; + } catch (error) { + debugError("업로드 파일 목록 조회 실패", error); + console.error("[fetchVendorUploadedFiles] 오류:", error); + throw new Error("업로드 파일 목록 조회 실패"); + } +} + +// ============================================================================ +// 벤더가 업로드한 파일 취소 (userId 파라미터 버전) +// ============================================================================ + +export interface CancelVendorUploadedFileParams { + boxSeq: string; + actvSeq: string; + userId: string; +} + +export async function cancelVendorUploadedFile(params: CancelVendorUploadedFileParams) { + debugProcess("벤더 업로드 파일 취소 시작", params); + + try { + const vendorInfo = await getVendorSessionInfo(); + + if (!vendorInfo) { + debugError("벤더 정보 없음"); + throw new Error("벤더 정보를 찾을 수 없습니다."); + } + + // api-client의 callSaveInBoxListCancelStatus 사용 + const { callSaveInBoxListCancelStatus } = await import("./api-client"); + const cancelCount = await callSaveInBoxListCancelStatus({ + boxSeq: params.boxSeq, + actvSeq: params.actvSeq, + chgr: `evcp${params.userId}`, + }); + + debugSuccess("업로드 파일 취소 완료", { + ...params, + cancelCount + }); + + return { + success: true, + cancelCount + }; + } catch (error) { + debugError("업로드 파일 취소 실패", error); + console.error("[cancelVendorUploadedFile] 오류:", error); + throw new Error("파일 취소 실패"); + } +} + +// ============================================================================ // 주의: 파일 업로드는 /api/swp/upload 라우트에서 처리됩니다 // ============================================================================ |
