컨트롤러 오류 수정
This commit is contained in:
@@ -9,27 +9,6 @@ const averageService = require('../services/averageService');
|
||||
exports.publicEventEntry = async (req, res) => {
|
||||
const { publicHash } = req.params;
|
||||
const { password } = req.body || {};
|
||||
|
||||
// 팀 핸디캡 수정
|
||||
exports.updateTeamHandicap = async (req, res) => {
|
||||
const { publicHash } = req.params;
|
||||
const { teamNumber, handicap } = req.body || {};
|
||||
try {
|
||||
const event = await Event.findOne({ where: { publicHash } });
|
||||
if (!event) return res.status(404).json({ message: '이벤트를 찾을 수 없습니다.' });
|
||||
if (event.status !== 'ready' && event.status !== 'active') return res.status(403).json({ message: '팀 핸디캡 수정이 불가능한 상태입니다.' });
|
||||
|
||||
const team = await EventTeam.findOne({ where: { eventId: event.id, teamNumber } });
|
||||
if (!team) return res.status(404).json({ message: '팀을 찾을 수 없습니다.' });
|
||||
|
||||
const hc = Number(handicap) || 0;
|
||||
await team.update({ handicap: hc });
|
||||
return res.json({ message: '팀 핸디캡이 저장되었습니다.', data: { teamNumber, handicap: hc } });
|
||||
} catch (e) {
|
||||
console.error('팀 핸디캡 수정 오류:', e);
|
||||
res.status(500).json({ message: '팀 핸디캡 저장 중 오류가 발생했습니다.' });
|
||||
}
|
||||
};
|
||||
const auth = req.headers.authorization;
|
||||
let event;
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user