From 4fcbdaff827e298ecd8a57939a287f61cc1b30d6 Mon Sep 17 00:00:00 2001 From: joonhoekim <26rote@gmail.com> Date: Fri, 24 Oct 2025 10:50:51 +0900 Subject: (김준회) 벤더 연락처 삭제 기능 구현 MDG vendor 송신부 csv에 설명 추가 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/vendors/service.ts | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'lib/vendors/service.ts') diff --git a/lib/vendors/service.ts b/lib/vendors/service.ts index 98c72349..6813f717 100644 --- a/lib/vendors/service.ts +++ b/lib/vendors/service.ts @@ -45,6 +45,7 @@ import type { GetVendorContactsSchema, CreateVendorContactSchema, UpdateVendorContactSchema, + DeleteVendorContactSchema, GetVendorItemsSchema, CreateVendorItemSchema, GetRfqHistorySchema, @@ -3680,4 +3681,33 @@ export async function getBidHistory(input: GetBidHistorySchema, vendorId: number console.error("Error fetching bid history:", err); return { data: [], pageCount: 0 }; } +} + +// deleteVendorContact 함수 추가 +export async function deleteVendorContact(input: DeleteVendorContactSchema) { + unstable_noStore(); // Next.js 서버 액션 캐싱 방지 + try { + await db.transaction(async (tx) => { + // DB Delete + await tx + .delete(vendorContacts) + .where(and( + eq(vendorContacts.id, input.id), + eq(vendorContacts.vendorId, input.vendorId) + )); + }); + + // 캐시 무효화 (협력업체 연락처 목록 등) + revalidateTag(`vendor-contacts-${input.vendorId}`); + + return { success: true, message: "Contact deleted successfully" }; + } catch (error) { + console.error("Error deleting vendor contact:", error); + return { + success: false, + message: error instanceof z.ZodError + ? error.errors[0].message + : "Failed to delete contact" + }; + } } \ No newline at end of file -- cgit v1.2.3