clubId 변경
This commit is contained in:
@@ -522,6 +522,11 @@ exports.saveEventFileData = async (req, res) => {
|
||||
if (!eventData || !participants || !clubId) {
|
||||
return res.status(400).json({ message: '이벤트 정보, 참가자 정보, 클럽 ID가 필요합니다.' });
|
||||
}
|
||||
// clubId 타입 보정 (문자열로 들어온 경우 Number로 변환)
|
||||
const cid = Number(clubId);
|
||||
if (!cid || Number.isNaN(cid)) {
|
||||
return res.status(400).json({ message: '유효한 클럽 ID가 필요합니다.' });
|
||||
}
|
||||
|
||||
try {
|
||||
// 트랜잭션 시작
|
||||
@@ -553,7 +558,7 @@ exports.saveEventFileData = async (req, res) => {
|
||||
if (eventData.id) {
|
||||
// 기존 이벤트 업데이트
|
||||
event = await Event.findOne({
|
||||
where: { id: eventData.id, clubId },
|
||||
where: { id: eventData.id, clubId: cid },
|
||||
transaction: t
|
||||
});
|
||||
|
||||
@@ -575,7 +580,7 @@ exports.saveEventFileData = async (req, res) => {
|
||||
} else {
|
||||
// 새 이벤트 생성
|
||||
event = await Event.create({
|
||||
clubId,
|
||||
clubId: cid,
|
||||
title: eventData.title,
|
||||
description: eventData.description || '',
|
||||
eventType: normalizeEventType(eventData.eventType),
|
||||
@@ -666,7 +671,7 @@ exports.saveEventFileData = async (req, res) => {
|
||||
} else {
|
||||
// 새 회원 생성 및 참가자 등록
|
||||
const newMember = await Member.create({
|
||||
clubId, // required by Member model
|
||||
clubId: cid, // required by Member model
|
||||
name: participant.name,
|
||||
// normalize enum values to match Member model
|
||||
gender: (participant.gender === 'female' || participant.gender === '여성') ? 'female' : 'male',
|
||||
@@ -676,7 +681,7 @@ exports.saveEventFileData = async (req, res) => {
|
||||
|
||||
// 클럽 회원으로 등록
|
||||
await ClubMember.create({
|
||||
clubId,
|
||||
clubId: cid,
|
||||
memberId: newMember.id,
|
||||
joinDate: new Date(),
|
||||
status: 'active'
|
||||
|
||||
Reference in New Issue
Block a user