From fa6a6093014c5d60188edfc9c4552e81c4b97bd1 Mon Sep 17 00:00:00 2001 From: dujinkim Date: Mon, 16 Jun 2025 01:11:01 +0000 Subject: (최겸) 기술영업 벤더 add 서버액션 수정 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/tech-vendors/service.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/tech-vendors/service.ts b/lib/tech-vendors/service.ts index 7513a283..05ec1178 100644 --- a/lib/tech-vendors/service.ts +++ b/lib/tech-vendors/service.ts @@ -1420,7 +1420,7 @@ export async function addTechVendor(input: { // 이미 존재하는 유저인지 확인 const existingUser = await tx.query.users.findFirst({ where: eq(users.email, input.email), - columns: { id: true } + columns: { id: true, techCompanyId: true } }); let userId = null; @@ -1435,7 +1435,15 @@ export async function addTechVendor(input: { userId = newUser.id; console.log("유저 생성 성공:", userId); } else { - console.log("이미 존재하는 유저:", existingUser.id); + // 이미 존재하는 유저의 techCompanyId가 null인 경우 업데이트 + if (!existingUser.techCompanyId) { + await tx.update(users) + .set({ techCompanyId: newVendor.id }) + .where(eq(users.id, existingUser.id)); + console.log("기존 유저의 techCompanyId 업데이트:", existingUser.id); + } + userId = existingUser.id; + console.log("이미 존재하는 유저:", userId); } return { vendor: newVendor, userId }; -- cgit v1.2.3