From 4a3a24e327dc774903c6ece901921572f2771c53 Mon Sep 17 00:00:00 2001 From: Jaybe Date: Wed, 22 Oct 2025 20:33:43 +0900 Subject: [PATCH] =?UTF-8?q?=ED=9A=8C=EC=9B=90=EB=93=B1=EB=A1=9D=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/controllers/fileUploadController.js | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/backend/controllers/fileUploadController.js b/backend/controllers/fileUploadController.js index 9aedd9f..dbc53b9 100644 --- a/backend/controllers/fileUploadController.js +++ b/backend/controllers/fileUploadController.js @@ -595,6 +595,8 @@ exports.saveEventFileData = async (req, res) => { } // 이벤트에서 최종 클럽ID 확정(추가 안정성) const effectiveClubId = Number(event.clubId); + // 클럽 인스턴스 로드 (조인 테이블 조작용) + const clubInstance = await Club.findOne({ where: { id: effectiveClubId, status: 'active' }, transaction: t }); // 1.5 팀 정보 처리 - 참가자 처리 전에 팀 생성 // 팀 번호별로 그룹화 @@ -681,13 +683,14 @@ exports.saveEventFileData = async (req, res) => { status: 'active' }, { transaction: t }); - // 클럽 회원으로 등록 - await ClubMember.create({ - clubId: effectiveClubId, - memberId: newMember.id, - joinDate: new Date(), - status: 'active' - }, { transaction: t }); + // 클럽 회원으로 등록 (조인 테이블을 association으로 처리) + if (!clubInstance) { + throw new Error('클럽을 찾을 수 없습니다.'); + } + await clubInstance.addMember(newMember, { + through: { joinDate: new Date(), status: 'active' }, + transaction: t, + }); // 팀 ID 가져오기 let teamId = null;