|
2 | 2 |
|
3 | 3 | import KKSC.page.domain.calendar.dto.EventRequest;
|
4 | 4 | import KKSC.page.domain.calendar.dto.EventResponse;
|
5 |
| -import KKSC.page.domain.calendar.exception.CalendarException; |
| 5 | +import KKSC.page.domain.calendar.dto.EventResponseInterface; |
| 6 | +import KKSC.page.domain.calendar.exception.EventException; |
6 | 7 | import KKSC.page.domain.calendar.repoAndService.EventService;
|
7 | 8 | import KKSC.page.global.auth.service.JwtService;
|
8 | 9 | import KKSC.page.global.exception.ErrorCode;
|
| 10 | +import KKSC.page.global.exception.dto.ErrorResponseVO; |
9 | 11 | import KKSC.page.global.exception.dto.ResponseVO;
|
| 12 | +import io.swagger.v3.oas.annotations.Operation; |
| 13 | +import io.swagger.v3.oas.annotations.Parameter; |
| 14 | +import io.swagger.v3.oas.annotations.Parameters; |
| 15 | +import io.swagger.v3.oas.annotations.media.Content; |
| 16 | +import io.swagger.v3.oas.annotations.media.Schema; |
| 17 | +import io.swagger.v3.oas.annotations.responses.ApiResponse; |
| 18 | +import io.swagger.v3.oas.annotations.responses.ApiResponses; |
| 19 | +import io.swagger.v3.oas.annotations.tags.Tag; |
10 | 20 | import jakarta.servlet.http.HttpServletRequest;
|
11 | 21 | import lombok.RequiredArgsConstructor;
|
| 22 | +import lombok.extern.slf4j.Slf4j; |
| 23 | + |
12 | 24 | import org.springframework.web.bind.annotation.*;
|
13 | 25 |
|
14 | 26 | import java.util.List;
|
15 | 27 |
|
| 28 | +@Tag(name = "Event", description = "일정관리 API") |
16 | 29 | @RestController
|
17 | 30 | @RequiredArgsConstructor
|
18 |
| -@RequestMapping("/calendar") |
| 31 | +@RequestMapping("/event") |
| 32 | +@Slf4j |
19 | 33 | public class EventController {
|
20 | 34 |
|
21 | 35 | private final EventService eventService;
|
22 | 36 | private final JwtService jwtService;
|
23 | 37 |
|
24 | 38 | // 캘린더 일정 추가
|
| 39 | + @ApiResponses(value = { |
| 40 | + @ApiResponse(responseCode = "200", description = "API 정상 작동",content = @Content(schema = @Schema(implementation = ResponseVO.class))), |
| 41 | + @ApiResponse(responseCode = "???", description = "서버 에러",content = @Content(schema = @Schema(implementation = ErrorResponseVO.class)))} |
| 42 | + ) |
| 43 | + @Operation(summary = "일정 추가", description = " 일정 추가 API ") |
25 | 44 | @PostMapping("/")
|
26 | 45 | public ResponseVO<Long> addEvent(@RequestBody EventRequest eventRequest) {
|
27 |
| - return new ResponseVO<>(eventService.createSchedule(eventRequest)); |
| 46 | + return new ResponseVO<>(eventService.createEvent(eventRequest)); |
28 | 47 | }
|
29 | 48 |
|
30 |
| - // 캘린더 일정 삭제 |
31 |
| - @DeleteMapping("/{id}") |
32 |
| - public ResponseVO<String> deleteEvent(@PathVariable Long id) { |
33 |
| - eventService.deleteSchedule(id); |
| 49 | + // 캘린더 일정 수정 |
| 50 | + @ApiResponses(value = { |
| 51 | + @ApiResponse(responseCode = "200", description = "API 정상 작동",content = @Content(schema = @Schema(implementation = ResponseVO.class))), |
| 52 | + @ApiResponse(responseCode = "???", description = "서버 에러",content = @Content(schema = @Schema(implementation = ErrorResponseVO.class)))} |
| 53 | + ) |
| 54 | + @Parameter(name = "eventId", description = "일정 번호") |
| 55 | + @Operation(summary = " 일정 수정 ", description = " 일정 수정 API ") |
| 56 | + @PutMapping("/{eventId}") |
| 57 | + public ResponseVO<EventResponse> updateEvent(@PathVariable Long eventId, @RequestBody EventRequest eventRequest) { |
| 58 | + return new ResponseVO<>(eventService.updateEvent(eventId, eventRequest)); |
| 59 | + } |
34 | 60 |
|
35 |
| - return new ResponseVO<>("Delete Success"); |
| 61 | + // 캘린더 일정 삭제 |
| 62 | + @ApiResponses(value = { |
| 63 | + @ApiResponse(responseCode = "200", description = "API 정상 작동",content = @Content(schema = @Schema(implementation = ResponseVO.class))), |
| 64 | + @ApiResponse(responseCode = "???", description = "서버 에러",content = @Content(schema = @Schema(implementation = ErrorResponseVO.class)))} |
| 65 | + ) |
| 66 | + @Parameter(name = "eventId", description = "일정 번호") |
| 67 | + @Operation(summary = " 일정 삭제 ", description = " 일정 삭제 API ") |
| 68 | + @DeleteMapping("/{eventId}") |
| 69 | + public ResponseVO<String> deleteEvent(@PathVariable Long eventId) { |
| 70 | + return new ResponseVO<>("Delete success"); |
36 | 71 | }
|
37 | 72 |
|
38 |
| - // 캘린더 일정 수정 |
39 |
| - @PutMapping("/{id}") |
40 |
| - public ResponseVO<EventResponse> updateEvent(@PathVariable Long id, @RequestBody EventRequest eventRequest) { |
41 |
| - return new ResponseVO<>(eventService.updateSchedule(id, eventRequest)); |
| 73 | + // 캘린더 일정 목록 조회 완성 |
| 74 | + @ApiResponses(value = { |
| 75 | + @ApiResponse(responseCode = "200", description = "API 정상 작동",content = @Content(schema = @Schema(implementation = ResponseVO.class))), |
| 76 | + @ApiResponse(responseCode = "???", description = "서버 에러",content = @Content(schema = @Schema(implementation = ErrorResponseVO.class)))} |
| 77 | + ) |
| 78 | + @Parameters({ |
| 79 | + @Parameter(name = "year", description = "일정 검색 년도"), |
| 80 | + @Parameter(name = "month", description = "일정 검색 월"), |
| 81 | + }) |
| 82 | + @Operation(summary = " 일정 조회 ", description = " 일정 조회 API ") |
| 83 | + @GetMapping("") |
| 84 | + public ResponseVO<List<EventResponseInterface>> getEventList(@RequestParam int year, @RequestParam int month) { |
| 85 | + return new ResponseVO<>(eventService.getEventList(year, month)); |
42 | 86 | }
|
43 | 87 |
|
44 | 88 | // 캘린더 일정 참가
|
45 |
| - @PostMapping("/{id}/join") |
46 |
| - public ResponseVO<Long> joinEvent(HttpServletRequest request, @PathVariable Long id) { |
| 89 | + @ApiResponses(value = { |
| 90 | + @ApiResponse(responseCode = "200", description = "API 정상 작동",content = @Content(schema = @Schema(implementation = ResponseVO.class))), |
| 91 | + @ApiResponse(responseCode = "???", description = "서버 에러",content = @Content(schema = @Schema(implementation = ErrorResponseVO.class)))} |
| 92 | + ) |
| 93 | + @Parameter(name = "eventId", description = "일정 번호") |
| 94 | + @Operation(summary = " 일정 참가 ", description = " 일정 참가 API ") |
| 95 | + @PostMapping("/join/{eventId}") |
| 96 | + public ResponseVO<Long> joinEvent(HttpServletRequest request, @PathVariable Long eventId) { |
47 | 97 | String username = jwtService.extractUsername(request)
|
48 |
| - .orElseThrow(() -> new CalendarException(ErrorCode.ACCESS_DENIED)); |
49 |
| - |
50 |
| - return new ResponseVO<>(eventService.joinSchedule(id, username)); |
| 98 | + .orElseThrow(() -> new EventException(ErrorCode.ACCESS_DENIED)); |
| 99 | + |
| 100 | + return new ResponseVO<>(eventService.joinEvent(eventId, username)); |
51 | 101 | }
|
52 |
| - |
| 102 | + |
53 | 103 | // 캘린더 일정 참가 취소
|
54 |
| - @DeleteMapping("/cancel/{id}") |
55 |
| - public ResponseVO<String> cancelEvent(@PathVariable Long id) { |
56 |
| - eventService.cancelSchedule(id); |
57 |
| - |
58 |
| - return new ResponseVO<>("Cancel Success"); |
59 |
| - } |
| 104 | + @ApiResponses(value = { |
| 105 | + @ApiResponse(responseCode = "200", description = "API 정상 작동",content = @Content(schema = @Schema(implementation = ResponseVO.class))), |
| 106 | + @ApiResponse(responseCode = "???", description = "서버 에러",content = @Content(schema = @Schema(implementation = ErrorResponseVO.class)))} |
| 107 | + ) |
| 108 | + @Parameter(name = "eventId", description = "일정 번호") |
| 109 | + @Operation(summary = " 일정 참가 취소 ", description = " 일정 참가 취소 API ") |
| 110 | + @DeleteMapping("/cancel/{eventId}") |
| 111 | + public ResponseVO<String> cancelEvent(HttpServletRequest request, @PathVariable Long eventId) { |
| 112 | + String username = jwtService.extractUsername(request) |
| 113 | + .orElseThrow(() -> new EventException(ErrorCode.ACCESS_DENIED)); |
60 | 114 |
|
61 |
| - // 캘린더 일정 목록 조회 |
62 |
| - @GetMapping("/") |
63 |
| - public ResponseVO<List<EventResponse>> getEventList(@RequestParam Long year, @RequestParam Long month) { |
64 |
| - return new ResponseVO<>(eventService.getScheduleList(year, month)); |
| 115 | + return new ResponseVO<>(eventService.cancelEvent(eventId, username)); |
65 | 116 | }
|
66 | 117 | }
|
0 commit comments