-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNotificationController.java
More file actions
47 lines (40 loc) · 1.62 KB
/
NotificationController.java
File metadata and controls
47 lines (40 loc) · 1.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package Mua.Mua_backend.domain.notification.controller;
import Mua.Mua_backend.domain.member.entity.Member;
import Mua.Mua_backend.domain.notification.controller.docs.NotificationControllerDocs;
import Mua.Mua_backend.domain.notification.dto.response.NotificationResponse;
import Mua.Mua_backend.domain.notification.service.NotificationService;
import lombok.RequiredArgsConstructor;
import org.springframework.http.ResponseEntity;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@RestController
@RequiredArgsConstructor
@RequestMapping("/api/notifications")
public class NotificationController implements NotificationControllerDocs {
private final NotificationService notificationService;
// 알림 목록 조회
@GetMapping
public List<NotificationResponse> getMyNotifications(
@AuthenticationPrincipal Member member
) {
return notificationService.getMyNotifications(member);
}
// 알림 읽음 처리
@PatchMapping("/{notificationId}/read")
public ResponseEntity<Void> readNotification(
@PathVariable Long notificationId,
@AuthenticationPrincipal Member member
) {
notificationService.readNotification(notificationId, member);
return ResponseEntity.ok().build();
}
// 알림 전체 삭제
@DeleteMapping
public ResponseEntity<Void> deleteMyNotifications(
@AuthenticationPrincipal Member member
) {
notificationService.deleteMyNotifications(member);
return ResponseEntity.noContent().build();
}
}