File tree Expand file tree Collapse file tree 3 files changed +76
-0
lines changed
noweekend-core/core-api/src/main/kotlin/noweekend/core/api Expand file tree Collapse file tree 3 files changed +76
-0
lines changed Original file line number Diff line number Diff line change @@ -55,6 +55,15 @@ class ScheduleController(
5555 return ApiResponse .success(schedule)
5656 }
5757
58+ @PutMapping(" /{id}/state" )
59+ override fun updateScheduleState (
60+ @CurrentUserId userId : String ,
61+ @PathVariable id : String ,
62+ @RequestParam(name = " is_complete" , required = true ) isComplete : Boolean ,
63+ ): ApiResponse <ScheduleResponse > {
64+ return ApiResponse .success(scheduleApplicationService.updateScheduleState(userId, id, isComplete))
65+ }
66+
5867 @DeleteMapping(" /{id}" )
5968 override fun deleteSchedule (@CurrentUserId userId : String , @PathVariable id : String ): ApiResponse <String > {
6069 scheduleApplicationService.deleteSchedule(userId, id)
Original file line number Diff line number Diff line change @@ -266,6 +266,46 @@ interface ScheduleControllerDocs {
266266 request : ScheduleUpdateRequest ,
267267 ): ApiResponse <ScheduleResponse >
268268
269+ @Operation(
270+ summary = " 캘린더: 일정 완료 여부 수정" ,
271+ description = " 일정의 상태를 변경합니다." ,
272+ responses = [
273+ SwaggerApiResponse (
274+ responseCode = " 200" ,
275+ description = " 일정 수정 성공" ,
276+ content = [
277+ Content (
278+ mediaType = " application/json" ,
279+ schema = Schema (implementation = ApiResponse ::class ),
280+ examples = [
281+ ExampleObject (
282+ name = " 예시 응답" ,
283+ value = """
284+ {
285+ "result": "SUCCESS",
286+ "data": {
287+ "id": "abc123",
288+ "title": "회의",
289+ "startTime": "2025-05-01T10:00:00",
290+ "endTime": "2025-05-01T11:00:00",
291+ "category": "COMPANY",
292+ "temperature": 3,
293+ "allDay": false,
294+ "alarmOption": "FIFTEEN_MINUTES_BEFORE",
295+ "completed": true
296+ },
297+ "error": null
298+ }
299+ """ ,
300+ ),
301+ ],
302+ ),
303+ ],
304+ ),
305+ ],
306+ )
307+ fun updateScheduleState (userId : String , id : String , isComplete : Boolean ): ApiResponse <ScheduleResponse >
308+
269309 @Operation(
270310 summary = " 캘린더: 일정 삭제" ,
271311 description = " 일정을 삭제합니다." ,
Original file line number Diff line number Diff line change @@ -31,6 +31,12 @@ interface ScheduleApplicationService {
3131 request : ScheduleUpdateRequest ,
3232 ): ScheduleResponse
3333
34+ fun updateScheduleState (
35+ userId : String ,
36+ scheduleId : String ,
37+ isComplete : Boolean ,
38+ ): ScheduleResponse
39+
3440 fun deleteSchedule (userId : String , scheduleId : String )
3541}
3642
@@ -141,6 +147,27 @@ class ScheduleApplicationServiceImpl(
141147 return savedSchedule.toResponse()
142148 }
143149
150+ override fun updateScheduleState (
151+ userId : String ,
152+ scheduleId : String ,
153+ isComplete : Boolean ,
154+ ): ScheduleResponse {
155+ val existingSchedule = scheduleReader.findScheduleById(scheduleId)
156+ ? : throw CoreException (ErrorType .NOT_FOUND_ERROR , " Schedule not found: $scheduleId " )
157+
158+ if (existingSchedule.userId != userId) {
159+ throw CoreException (ErrorType .FORBIDDEN_ERROR , " You don't have permission to update this schedule" )
160+ }
161+
162+ if (existingSchedule.completed == isComplete) {
163+ return existingSchedule.toResponse()
164+ }
165+
166+ val updatedSchedule = existingSchedule.copy(completed = isComplete)
167+ val savedSchedule = scheduleWriter.update(updatedSchedule)
168+ return savedSchedule.toResponse()
169+ }
170+
144171 override fun deleteSchedule (userId : String , scheduleId : String ) {
145172 val existingSchedule = scheduleReader.findScheduleById(scheduleId)
146173 ? : throw CoreException (ErrorType .NOT_FOUND_ERROR , " Schedule not found: $scheduleId " )
You can’t perform that action at this time.
0 commit comments