Skip to content

Commit 3672a3e

Browse files
authored
[DOCS] 알림 관련 api 명세 추가 및 인증로직 도입 (#126)
* [DOCS] 알림 관련 swagger 명세 작성 * [FEAT] 인증 처리 추가 * [REFACTOR] 사용하지 않는 import 제거 * [REFACTOR] 필요하지 않은 SecurityRequirement 삭제 * [REFACTOR] 필요하지 않은 SecurityRequirement 삭제
1 parent 95bc781 commit 3672a3e

File tree

1 file changed

+29
-20
lines changed

1 file changed

+29
-20
lines changed

src/main/java/com/brainpix/alarm/controller/AlarmController.java

Lines changed: 29 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,92 +7,101 @@
77
import org.springframework.web.bind.annotation.PatchMapping;
88
import org.springframework.web.bind.annotation.PathVariable;
99
import org.springframework.web.bind.annotation.RequestMapping;
10-
import org.springframework.web.bind.annotation.RequestParam;
11-
import org.springframework.web.bind.annotation.RequestPart;
1210
import org.springframework.web.bind.annotation.RestController;
1311

1412
import com.brainpix.alarm.dto.GetAlarmDto;
1513
import com.brainpix.alarm.dto.GetUnreadAlarmDto;
1614
import com.brainpix.alarm.service.AlarmService;
1715
import com.brainpix.api.ApiResponse;
16+
import com.brainpix.security.authorization.AllUser;
17+
import com.brainpix.security.authorization.UserId;
1818

19+
import io.swagger.v3.oas.annotations.Operation;
20+
import io.swagger.v3.oas.annotations.tags.Tag;
1921
import lombok.RequiredArgsConstructor;
2022

2123
@RestController
2224
@RequiredArgsConstructor
2325
@RequestMapping("/alarm")
26+
@Tag(name = "Alarm", description = "알림 관련 API")
2427
public class AlarmController {
2528

2629
private final AlarmService alarmService;
2730

28-
// 알림 읽음 처리 API
31+
@AllUser
2932
@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) {
3135

3236
alarmService.readAlarm(alarmId, userId);
3337

3438
return ResponseEntity.ok(ApiResponse.successWithNoData());
3539
}
3640

37-
// 일반 알림 조회 API
38-
// 시큐리티 적용 전까지 임시로 userId를 RequestParam 으로 받아서 사용
41+
@AllUser
3942
@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) {
4145

4246
GetAlarmDto.Response data = alarmService.getAlarm(pageable, userId);
4347

4448
return ResponseEntity.ok(ApiResponse.success(data));
4549
}
4650

47-
// 휴지통 알림 조회 API
48-
// 시큐리티 적용 전까지 임시로 userId를 RequestParam 으로 받아서 사용
51+
@AllUser
4952
@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) {
5155

5256
GetAlarmDto.Response data = alarmService.getTrashAlarm(pageable, userId);
5357

5458
return ResponseEntity.ok(ApiResponse.success(data));
5559
}
5660

57-
// 알림 수 조회 API
61+
@AllUser
5862
@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) {
6065

6166
GetUnreadAlarmDto.Response data = alarmService.getUnreadAlarmCount(userId);
6267

6368
return ResponseEntity.ok(ApiResponse.success(data));
6469
}
6570

66-
// 알림 휴지통으로 보내기 API
71+
@AllUser
6772
@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) {
6975

7076
alarmService.addTrashAlarm(alarmId, userId);
7177

7278
return ResponseEntity.ok(ApiResponse.successWithNoData());
7379
}
7480

75-
// 알림 휴지통에서 복구 API
81+
@AllUser
7682
@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) {
7885

7986
alarmService.restoreAlarm(alarmId, userId);
8087

8188
return ResponseEntity.ok(ApiResponse.successWithNoData());
8289
}
8390

84-
// 알림 삭제 API
91+
@AllUser
8592
@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) {
8795

8896
alarmService.deleteOneAlarm(alarmId, userId);
8997

9098
return ResponseEntity.ok(ApiResponse.successWithNoData());
9199
}
92100

93-
// 알림 전체 삭제 API
101+
@AllUser
94102
@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) {
96105

97106
alarmService.deleteAllAlarm(userId);
98107

0 commit comments

Comments
 (0)