참가비 필드 수정
This commit is contained in:
@@ -159,7 +159,9 @@ exports.createEvent = async (req, res) => {
|
|||||||
location,
|
location,
|
||||||
maxParticipants,
|
maxParticipants,
|
||||||
eventType,
|
eventType,
|
||||||
|
participantFee,
|
||||||
entryFee,
|
entryFee,
|
||||||
|
fee,
|
||||||
gameCount,
|
gameCount,
|
||||||
laneCount,
|
laneCount,
|
||||||
status
|
status
|
||||||
@@ -196,6 +198,14 @@ exports.createEvent = async (req, res) => {
|
|||||||
const publicHash = await generateRandomHash();
|
const publicHash = await generateRandomHash();
|
||||||
const accessPassword = req.body.accessPassword || null;
|
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({
|
const event = await Event.create({
|
||||||
clubId,
|
clubId,
|
||||||
title,
|
title,
|
||||||
@@ -204,11 +214,11 @@ exports.createEvent = async (req, res) => {
|
|||||||
endDate: endDateVal,
|
endDate: endDateVal,
|
||||||
location,
|
location,
|
||||||
maxParticipants: maxParticipants || 0,
|
maxParticipants: maxParticipants || 0,
|
||||||
eventType: eventType || '일반',
|
eventType: eventType || 'regular',
|
||||||
entryFee: entryFee || 0,
|
participantFee: feeParsed ?? 0,
|
||||||
gameCount: gameCount || 3,
|
gameCount: gameCount || 3,
|
||||||
laneCount: laneCount || 1,
|
laneCount: laneCount || 1,
|
||||||
status: status || '활성',
|
status: status || 'active',
|
||||||
publicHash,
|
publicHash,
|
||||||
accessPassword
|
accessPassword
|
||||||
});
|
});
|
||||||
@@ -568,7 +578,9 @@ exports.updateEvent = async (req, res) => {
|
|||||||
location,
|
location,
|
||||||
maxParticipants,
|
maxParticipants,
|
||||||
eventType,
|
eventType,
|
||||||
|
participantFee,
|
||||||
entryFee,
|
entryFee,
|
||||||
|
fee,
|
||||||
gameCount,
|
gameCount,
|
||||||
laneCount,
|
laneCount,
|
||||||
status,
|
status,
|
||||||
@@ -597,6 +609,14 @@ exports.updateEvent = async (req, res) => {
|
|||||||
if(endDate == 'Invalid Date') {
|
if(endDate == 'Invalid Date') {
|
||||||
endDate = null;
|
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 = {
|
const updateData = {
|
||||||
title,
|
title,
|
||||||
description,
|
description,
|
||||||
@@ -604,11 +624,11 @@ exports.updateEvent = async (req, res) => {
|
|||||||
endDate: endDate || null,
|
endDate: endDate || null,
|
||||||
location,
|
location,
|
||||||
maxParticipants: maxParticipants || event.maxParticipants,
|
maxParticipants: maxParticipants || event.maxParticipants,
|
||||||
eventType: eventType || event.eventType,
|
eventType: eventType || event.eventType || 'regular',
|
||||||
entryFee: entryFee !== undefined ? entryFee : event.entryFee,
|
participantFee: feeParsed !== null ? feeParsed : event.participantFee,
|
||||||
gameCount: gameCount || event.gameCount,
|
gameCount: gameCount || event.gameCount,
|
||||||
laneCount: laneCount || event.laneCount,
|
laneCount: laneCount || event.laneCount,
|
||||||
status: status || event.status,
|
status: status || event.status || 'active',
|
||||||
registrationDeadline: registrationDeadline || event.registrationDeadline,
|
registrationDeadline: registrationDeadline || event.registrationDeadline,
|
||||||
publicHash: publicHash || event.publicHash,
|
publicHash: publicHash || event.publicHash,
|
||||||
accessPassword: accessPassword || null
|
accessPassword: accessPassword || null
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ const Event = sequelize.define('Event', {
|
|||||||
participantFee: {
|
participantFee: {
|
||||||
type: DataTypes.DECIMAL(10, 2),
|
type: DataTypes.DECIMAL(10, 2),
|
||||||
allowNull: false,
|
allowNull: false,
|
||||||
defaultValue: 0,
|
defaultValue: null,
|
||||||
comment: '참가비'
|
comment: '참가비'
|
||||||
},
|
},
|
||||||
maxParticipants: {
|
maxParticipants: {
|
||||||
|
|||||||
Reference in New Issue
Block a user