From ec2bcdeb6a918bcf2b472bfabbe065d140b22782 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=A1=B0=EB=8C=80=ED=9D=AC?= <joedaehui@ajou.ac.kr> Date: Fri, 15 Nov 2024 10:59:03 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=ED=8A=B9=EC=A0=95=20=EC=8A=A4=EC=BC=80?= =?UTF-8?q?=EC=A4=84=20=EC=A1=B0=ED=9A=8C=20=EC=BB=A8=ED=8A=B8=EB=A1=A4?= =?UTF-8?q?=EB=9F=AC=20(#6)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- controllers/scheduleController.js | 41 +++++++++++++++++++++++++++++-- 1 file changed, 39 insertions(+), 2 deletions(-) diff --git a/controllers/scheduleController.js b/controllers/scheduleController.js index 666917b..9a148f3 100644 --- a/controllers/scheduleController.js +++ b/controllers/scheduleController.js @@ -55,7 +55,7 @@ class scheduleController { end_time }); - return res.statu(200).json({ + return res.status(200).json({ success: true, data: schedule }); @@ -130,4 +130,41 @@ class scheduleController { }); } } -} \ No newline at end of file + + /** + * 해당 사용자 특정 스케줄 조회 + * GET /api/schedule/:id + */ + async getScheduleById(req, res) { + try { + const { id } = req.params; + const userId = req.user.id; + const schedule = await ScheduleService.getScheduleById(id, userId); + + return res.status(200).json({ + success: true, + data: schedule + }); + } catch (error) { + if (error.message === 'Schedule not found') { + return res.status(404).json({ + success: false, + error: { + message: error.message, + code: 'SCHEDULE_NOT_FOUND' + } + }); + } + + return res.status(500).json({ + success: false, + error: { + message: 'Failed to fetch schedule', + code: 'FETCH_ERROR' + } + }); + } + } +} + +module.exports = new ScheduleController(); \ No newline at end of file -- GitLab