diff --git a/backend/controllers/publicController.js b/backend/controllers/publicController.js index c71e651..1bbb9ae 100644 --- a/backend/controllers/publicController.js +++ b/backend/controllers/publicController.js @@ -417,3 +417,24 @@ exports.updatePublicScore = async (req, res) => { res.status(500).json({ message: '점수 저장 중 오류가 발생했습니다.' }); } }; + +// 팀 핸디캡 수정 (top-level export) +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: '팀 핸디캡 저장 중 오류가 발생했습니다.' }); + } +};