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