참가비 오류 수정
This commit is contained in:
@@ -199,12 +199,21 @@ exports.createEvent = async (req, res) => {
|
||||
const accessPassword = req.body.accessPassword || null;
|
||||
|
||||
// 금액 통합: 문자열("20000.00") 또는 숫자를 허용, 0은 유효값(무료), 빈값은 null 처리
|
||||
let feeRaw = fee ?? entryFee ?? participantFee;
|
||||
const hasFeeField = Object.prototype.hasOwnProperty.call(req.body, 'participantFee')
|
||||
|| Object.prototype.hasOwnProperty.call(req.body, 'entryFee')
|
||||
|| Object.prototype.hasOwnProperty.call(req.body, 'fee');
|
||||
let feeParsed = null;
|
||||
if (feeRaw !== undefined && feeRaw !== null && `${feeRaw}`.trim() !== '') {
|
||||
if (hasFeeField) {
|
||||
const feeRaw = fee ?? entryFee ?? participantFee;
|
||||
if (feeRaw === undefined || feeRaw === null || `${feeRaw}`.trim() === '') {
|
||||
feeParsed = null; // 명시적 빈값 => null 저장
|
||||
} else {
|
||||
const num = parseFloat(`${feeRaw}`);
|
||||
feeParsed = Number.isFinite(num) ? num : null;
|
||||
}
|
||||
} else {
|
||||
feeParsed = null; // 생성 시 미제공이면 null 유지
|
||||
}
|
||||
|
||||
const event = await Event.create({
|
||||
clubId,
|
||||
@@ -215,7 +224,7 @@ exports.createEvent = async (req, res) => {
|
||||
location,
|
||||
maxParticipants: maxParticipants || 0,
|
||||
eventType: eventType || 'regular',
|
||||
participantFee: feeParsed ?? 0,
|
||||
participantFee: feeParsed, // allowNull=true이므로 null 저장 허용
|
||||
gameCount: gameCount || 3,
|
||||
laneCount: laneCount || 1,
|
||||
status: status || 'active',
|
||||
@@ -609,13 +618,20 @@ 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() !== '') {
|
||||
// 금액 통합: 문자열("20000.00") 또는 숫자를 허용, 0은 유효값(무료), 빈값은 null 처리
|
||||
const hasFeeField = Object.prototype.hasOwnProperty.call(req.body, 'participantFee')
|
||||
|| Object.prototype.hasOwnProperty.call(req.body, 'entryFee')
|
||||
|| Object.prototype.hasOwnProperty.call(req.body, 'fee');
|
||||
let feeParsed = undefined; // 업데이트에서 undefined면 필드 미변경
|
||||
if (hasFeeField) {
|
||||
const feeRaw = fee ?? entryFee ?? participantFee;
|
||||
if (feeRaw === undefined || feeRaw === null || `${feeRaw}`.trim() === '') {
|
||||
feeParsed = null; // 명시적 빈값 => null로 클리어
|
||||
} else {
|
||||
const num = parseFloat(`${feeRaw}`);
|
||||
feeParsed = Number.isFinite(num) ? num : null;
|
||||
}
|
||||
}
|
||||
|
||||
const updateData = {
|
||||
title,
|
||||
@@ -625,7 +641,7 @@ exports.updateEvent = async (req, res) => {
|
||||
location,
|
||||
maxParticipants: maxParticipants || event.maxParticipants,
|
||||
eventType: eventType || event.eventType || 'regular',
|
||||
participantFee: feeParsed !== null ? feeParsed : event.participantFee,
|
||||
...(feeParsed !== undefined ? { participantFee: feeParsed } : {}),
|
||||
gameCount: gameCount || event.gameCount,
|
||||
laneCount: laneCount || event.laneCount,
|
||||
status: status || event.status || 'active',
|
||||
|
||||
Reference in New Issue
Block a user