|
7 | 7 | import org.springframework.web.bind.annotation.PatchMapping; |
8 | 8 | import org.springframework.web.bind.annotation.PathVariable; |
9 | 9 | import org.springframework.web.bind.annotation.RequestMapping; |
10 | | -import org.springframework.web.bind.annotation.RequestParam; |
11 | | -import org.springframework.web.bind.annotation.RequestPart; |
12 | 10 | import org.springframework.web.bind.annotation.RestController; |
13 | 11 |
|
14 | 12 | import com.brainpix.alarm.dto.GetAlarmDto; |
15 | 13 | import com.brainpix.alarm.dto.GetUnreadAlarmDto; |
16 | 14 | import com.brainpix.alarm.service.AlarmService; |
17 | 15 | import com.brainpix.api.ApiResponse; |
| 16 | +import com.brainpix.security.authorization.AllUser; |
| 17 | +import com.brainpix.security.authorization.UserId; |
18 | 18 |
|
| 19 | +import io.swagger.v3.oas.annotations.Operation; |
| 20 | +import io.swagger.v3.oas.annotations.tags.Tag; |
19 | 21 | import lombok.RequiredArgsConstructor; |
20 | 22 |
|
21 | 23 | @RestController |
22 | 24 | @RequiredArgsConstructor |
23 | 25 | @RequestMapping("/alarm") |
| 26 | +@Tag(name = "Alarm", description = "알림 관련 API") |
24 | 27 | public class AlarmController { |
25 | 28 |
|
26 | 29 | private final AlarmService alarmService; |
27 | 30 |
|
28 | | - // 알림 읽음 처리 API |
| 31 | + @AllUser |
29 | 32 | @PatchMapping("/read/{alarmId}") |
30 | | - public ResponseEntity<ApiResponse<Void>> readAlarm(@PathVariable String alarmId, @RequestParam Long userId) { |
| 33 | + @Operation(summary = "알림 읽음 처리 API", description = "알림을 읽음 처리합니다.") |
| 34 | + public ResponseEntity<ApiResponse<Void>> readAlarm(@PathVariable String alarmId, @UserId Long userId) { |
31 | 35 |
|
32 | 36 | alarmService.readAlarm(alarmId, userId); |
33 | 37 |
|
34 | 38 | return ResponseEntity.ok(ApiResponse.successWithNoData()); |
35 | 39 | } |
36 | 40 |
|
37 | | - // 일반 알림 조회 API |
38 | | - // 시큐리티 적용 전까지 임시로 userId를 RequestParam 으로 받아서 사용 |
| 41 | + @AllUser |
39 | 42 | @GetMapping |
40 | | - public ResponseEntity<ApiResponse<GetAlarmDto.Response>> getAlarmList(Pageable pageable, @RequestParam Long userId) { |
| 43 | + @Operation(summary = "알림 다건 조회 API", description = "여러건의 알림을 조회합니다.") |
| 44 | + public ResponseEntity<ApiResponse<GetAlarmDto.Response>> getAlarmList(Pageable pageable, @UserId Long userId) { |
41 | 45 |
|
42 | 46 | GetAlarmDto.Response data = alarmService.getAlarm(pageable, userId); |
43 | 47 |
|
44 | 48 | return ResponseEntity.ok(ApiResponse.success(data)); |
45 | 49 | } |
46 | 50 |
|
47 | | - // 휴지통 알림 조회 API |
48 | | - // 시큐리티 적용 전까지 임시로 userId를 RequestParam 으로 받아서 사용 |
| 51 | + @AllUser |
49 | 52 | @GetMapping("/trash") |
50 | | - public ResponseEntity<ApiResponse<GetAlarmDto.Response>> getTrashAlarmList(Pageable pageable, @RequestPart Long userId) { |
| 53 | + @Operation(summary = "휴지통 알림 조회 API", description = "휴지통에 있는 알림들을 조회합니다.") |
| 54 | + public ResponseEntity<ApiResponse<GetAlarmDto.Response>> getTrashAlarmList(Pageable pageable, @UserId Long userId) { |
51 | 55 |
|
52 | 56 | GetAlarmDto.Response data = alarmService.getTrashAlarm(pageable, userId); |
53 | 57 |
|
54 | 58 | return ResponseEntity.ok(ApiResponse.success(data)); |
55 | 59 | } |
56 | 60 |
|
57 | | - // 알림 수 조회 API |
| 61 | + @AllUser |
58 | 62 | @GetMapping("/count") |
59 | | - public ResponseEntity<ApiResponse<GetUnreadAlarmDto.Response>> getUnreadAlarmCount(@RequestParam Long userId) { |
| 63 | + @Operation(summary = "알림 개수 조회 API", description = "알림 개수를 조회합니다.") |
| 64 | + public ResponseEntity<ApiResponse<GetUnreadAlarmDto.Response>> getUnreadAlarmCount(@UserId Long userId) { |
60 | 65 |
|
61 | 66 | GetUnreadAlarmDto.Response data = alarmService.getUnreadAlarmCount(userId); |
62 | 67 |
|
63 | 68 | return ResponseEntity.ok(ApiResponse.success(data)); |
64 | 69 | } |
65 | 70 |
|
66 | | - // 알림 휴지통으로 보내기 API |
| 71 | + @AllUser |
67 | 72 | @PatchMapping("/trash/{alarmId}") |
68 | | - public ResponseEntity<ApiResponse<Void>> addTrashAlarm(@PathVariable String alarmId, @RequestParam Long userId) { |
| 73 | + @Operation(summary = "알림 휴지통으로 보내기 API", description = "알림 하나를 휴지통으로 보냅니다.") |
| 74 | + public ResponseEntity<ApiResponse<Void>> addTrashAlarm(@PathVariable String alarmId, @UserId Long userId) { |
69 | 75 |
|
70 | 76 | alarmService.addTrashAlarm(alarmId, userId); |
71 | 77 |
|
72 | 78 | return ResponseEntity.ok(ApiResponse.successWithNoData()); |
73 | 79 | } |
74 | 80 |
|
75 | | - // 알림 휴지통에서 복구 API |
| 81 | + @AllUser |
76 | 82 | @PatchMapping("/restore/{alarmId}") |
77 | | - public ResponseEntity<ApiResponse<Void>> restoreAlarm(@PathVariable String alarmId, @RequestParam Long userId) { |
| 83 | + @Operation(summary = "휴지통에서 알림 복구 API", description = "휴지통에서 알림을 복구합니다.") |
| 84 | + public ResponseEntity<ApiResponse<Void>> restoreAlarm(@PathVariable String alarmId, @UserId Long userId) { |
78 | 85 |
|
79 | 86 | alarmService.restoreAlarm(alarmId, userId); |
80 | 87 |
|
81 | 88 | return ResponseEntity.ok(ApiResponse.successWithNoData()); |
82 | 89 | } |
83 | 90 |
|
84 | | - // 알림 삭제 API |
| 91 | + @AllUser |
85 | 92 | @DeleteMapping("/delete/{alarmId}") |
86 | | - public ResponseEntity<ApiResponse<Void>> deleteAlarm(@PathVariable String alarmId, @RequestParam Long userId) { |
| 93 | + @Operation(summary = "휴지통에서 알림 하나 삭제 API", description = "휴지통에 있는 알림 하나를 삭제합니다.") |
| 94 | + public ResponseEntity<ApiResponse<Void>> deleteAlarm(@PathVariable String alarmId, @UserId Long userId) { |
87 | 95 |
|
88 | 96 | alarmService.deleteOneAlarm(alarmId, userId); |
89 | 97 |
|
90 | 98 | return ResponseEntity.ok(ApiResponse.successWithNoData()); |
91 | 99 | } |
92 | 100 |
|
93 | | - // 알림 전체 삭제 API |
| 101 | + @AllUser |
94 | 102 | @DeleteMapping("/delete") |
95 | | - public ResponseEntity<ApiResponse<Void>> deleteAllAlarm(@RequestParam Long userId) { |
| 103 | + @Operation(summary = "휴지통에서 알림 전체 삭제 API", description = "휴지통에 있는 알림 전체를 삭제합니다.") |
| 104 | + public ResponseEntity<ApiResponse<Void>> deleteAllAlarm(@UserId Long userId) { |
96 | 105 |
|
97 | 106 | alarmService.deleteAllAlarm(userId); |
98 | 107 |
|
|
0 commit comments