|
12 | 12 | import jakarta.validation.Valid; |
13 | 13 | import jakarta.validation.constraints.Max; |
14 | 14 | import jakarta.validation.constraints.Min; |
| 15 | +import java.time.LocalDateTime; |
15 | 16 | import lombok.RequiredArgsConstructor; |
16 | 17 | import org.springframework.format.annotation.DateTimeFormat; |
17 | 18 | import org.springframework.security.access.prepost.PreAuthorize; |
|
20 | 21 | import org.springframework.web.bind.annotation.*; |
21 | 22 | import org.springframework.web.servlet.mvc.method.annotation.SseEmitter; |
22 | 23 |
|
23 | | -import java.time.LocalDateTime; |
24 | | - |
25 | 24 | @RestController |
26 | 25 | @RequestMapping("/me") |
27 | 26 | @RequiredArgsConstructor |
@@ -120,7 +119,17 @@ public RsData<NotificationGoResponseDto> goPostLink( |
120 | 119 | @PathVariable("id") Long notificationId |
121 | 120 | ) { |
122 | 121 | Long userId = principal.getId(); |
123 | | - var body = notificationService.markAsReadAndGetPostLink(userId, notificationId); |
| 122 | + NotificationGoResponseDto body = notificationService.markAsReadAndGetPostLink(userId, notificationId); |
124 | 123 | return RsData.successOf(body); |
125 | 124 | } |
| 125 | + |
| 126 | + @DeleteMapping("/notifications") |
| 127 | + @Operation(summary = "Delete all notifications", description = "Remove every notification belonging to the authenticated user") |
| 128 | + public RsData<Void> deleteNotifications( |
| 129 | + @AuthenticationPrincipal SecurityUser principal |
| 130 | + ) { |
| 131 | + Long userId = principal.getId(); |
| 132 | + notificationService.deleteAll(userId); |
| 133 | + return RsData.of(200, "cleared"); |
| 134 | + } |
126 | 135 | } |
0 commit comments