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