Skip to content
Snippets Groups Projects
Commit 24b9c992 authored by 조대희's avatar 조대희
Browse files

feat: 스케줄 수정 컨트롤러 (#6)

parent 360e88be
No related branches found
No related tags found
2 merge requests!31Develop,!7[#6] Schedule 컨트롤러, 라우터, 로직 개발
const { success } = require('../passport/googleStrategy');
const ScheduleService = require('../services/scheduleService'); const ScheduleService = require('../services/scheduleService');
class scheduleController { class scheduleController {
/** /**
* 스케줄 생성 * 스케줄 생성
* POST /api/schedules * POST /api/schedule
* 해당 사용자 id는 auth 미들웨어에서 설정된 사용자 정보 이용 * 해당 사용자 id는 auth 미들웨어에서 설정된 사용자 정보 이용
* req.user = User 모델의 인스턴스 * req.user = User 모델의 인스턴스
*/ */
...@@ -36,4 +37,44 @@ class scheduleController { ...@@ -36,4 +37,44 @@ class scheduleController {
}); });
} }
} }
/**
* 스케줄 수정
* PUT /api/schedule/:id
*/
async updateSchedule(req, res) {
try {
const { id } = req.params;
const { title, start_time, end_time } = req.body;
const userId = req.user.id;
const schedule = await ScheduleService.updateSchedule(id, userId,
{
title,
start_time,
end_time
});
return res.statu(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(400).json({
success: false,
error: {
message: error.message,
code: 'SCHEDULE_UPDATE_ERROR'
}
});
}
} }
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment