Skip to content

Commit 7e024e6

Browse files
committed
feat: NotificationController에 모든 알림을 삭제하는 DELETE /me/notifications 엔드포인트 구현
1 parent e411a15 commit 7e024e6

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

src/main/java/com/back/domain/notification/controller/NotificationController.java

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import jakarta.validation.Valid;
1313
import jakarta.validation.constraints.Max;
1414
import jakarta.validation.constraints.Min;
15+
import java.time.LocalDateTime;
1516
import lombok.RequiredArgsConstructor;
1617
import org.springframework.format.annotation.DateTimeFormat;
1718
import org.springframework.security.access.prepost.PreAuthorize;
@@ -20,8 +21,6 @@
2021
import org.springframework.web.bind.annotation.*;
2122
import org.springframework.web.servlet.mvc.method.annotation.SseEmitter;
2223

23-
import java.time.LocalDateTime;
24-
2524
@RestController
2625
@RequestMapping("/me")
2726
@RequiredArgsConstructor
@@ -120,7 +119,17 @@ public RsData<NotificationGoResponseDto> goPostLink(
120119
@PathVariable("id") Long notificationId
121120
) {
122121
Long userId = principal.getId();
123-
var body = notificationService.markAsReadAndGetPostLink(userId, notificationId);
122+
NotificationGoResponseDto body = notificationService.markAsReadAndGetPostLink(userId, notificationId);
124123
return RsData.successOf(body);
125124
}
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+
}
126135
}

0 commit comments

Comments
 (0)