diff --git a/backend/controllers/eventController.js b/backend/controllers/eventController.js index 930bd50..42a4234 100644 --- a/backend/controllers/eventController.js +++ b/backend/controllers/eventController.js @@ -159,7 +159,9 @@ exports.createEvent = async (req, res) => { location, maxParticipants, eventType, + participantFee, entryFee, + fee, gameCount, laneCount, status @@ -196,6 +198,14 @@ exports.createEvent = async (req, res) => { const publicHash = await generateRandomHash(); const accessPassword = req.body.accessPassword || null; + // 금액 통합: 문자열("20000.00") 또는 숫자를 허용, 0은 유효값(무료), 빈값은 null 처리 + let feeRaw = fee ?? entryFee ?? participantFee; + let feeParsed = null; + if (feeRaw !== undefined && feeRaw !== null && `${feeRaw}`.trim() !== '') { + const num = parseFloat(`${feeRaw}`); + feeParsed = Number.isFinite(num) ? num : null; + } + const event = await Event.create({ clubId, title, @@ -204,11 +214,11 @@ exports.createEvent = async (req, res) => { endDate: endDateVal, location, maxParticipants: maxParticipants || 0, - eventType: eventType || '일반', - entryFee: entryFee || 0, + eventType: eventType || 'regular', + participantFee: feeParsed ?? 0, gameCount: gameCount || 3, laneCount: laneCount || 1, - status: status || '활성', + status: status || 'active', publicHash, accessPassword }); @@ -568,7 +578,9 @@ exports.updateEvent = async (req, res) => { location, maxParticipants, eventType, + participantFee, entryFee, + fee, gameCount, laneCount, status, @@ -597,6 +609,14 @@ exports.updateEvent = async (req, res) => { if(endDate == 'Invalid Date') { endDate = null; } + // 금액 통합: 문자열("20000.00") 또는 숫자를 허용, 0은 유효값(무료) + let feeRaw = fee ?? entryFee ?? participantFee; + let feeParsed = null; + if (feeRaw !== undefined && feeRaw !== null && `${feeRaw}`.trim() !== '') { + const num = parseFloat(`${feeRaw}`); + feeParsed = Number.isFinite(num) ? num : null; + } + const updateData = { title, description, @@ -604,11 +624,11 @@ exports.updateEvent = async (req, res) => { endDate: endDate || null, location, maxParticipants: maxParticipants || event.maxParticipants, - eventType: eventType || event.eventType, - entryFee: entryFee !== undefined ? entryFee : event.entryFee, + eventType: eventType || event.eventType || 'regular', + participantFee: feeParsed !== null ? feeParsed : event.participantFee, gameCount: gameCount || event.gameCount, laneCount: laneCount || event.laneCount, - status: status || event.status, + status: status || event.status || 'active', registrationDeadline: registrationDeadline || event.registrationDeadline, publicHash: publicHash || event.publicHash, accessPassword: accessPassword || null diff --git a/backend/models/Event.js b/backend/models/Event.js index d856438..40c5494 100644 --- a/backend/models/Event.js +++ b/backend/models/Event.js @@ -67,7 +67,7 @@ const Event = sequelize.define('Event', { participantFee: { type: DataTypes.DECIMAL(10, 2), allowNull: false, - defaultValue: 0, + defaultValue: null, comment: '참가비' }, maxParticipants: {