참가비 필드 수정

This commit is contained in:
2025-10-16 11:05:37 +09:00
parent 694fed1b19
commit 561400843c
2 changed files with 27 additions and 7 deletions
+26 -6
View File
@@ -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
+1 -1
View File
@@ -67,7 +67,7 @@ const Event = sequelize.define('Event', {
participantFee: {
type: DataTypes.DECIMAL(10, 2),
allowNull: false,
defaultValue: 0,
defaultValue: null,
comment: '참가비'
},
maxParticipants: {