Skip to content

Commit 3a5ffdf

Browse files
committed
feat(NotificationCommandController): 읽음 처리 엔드포인트
- 1건, N건
1 parent dd9b79d commit 3a5ffdf

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
package com.somemore.notification.controller;
2+
3+
import com.somemore.auth.annotation.CurrentUser;
4+
import com.somemore.global.common.response.ApiResponse;
5+
import com.somemore.notification.dto.NotificationIdsRequestDto;
6+
import com.somemore.notification.usecase.NotificationCommandUseCase;
7+
import io.swagger.v3.oas.annotations.Operation;
8+
import io.swagger.v3.oas.annotations.tags.Tag;
9+
import lombok.RequiredArgsConstructor;
10+
import org.springframework.security.access.annotation.Secured;
11+
import org.springframework.web.bind.annotation.PatchMapping;
12+
import org.springframework.web.bind.annotation.PathVariable;
13+
import org.springframework.web.bind.annotation.PostMapping;
14+
import org.springframework.web.bind.annotation.RequestBody;
15+
import org.springframework.web.bind.annotation.RequestMapping;
16+
import org.springframework.web.bind.annotation.RestController;
17+
18+
import java.util.UUID;
19+
20+
@Tag(name = "Notification Command API", description = "알림 읽음 처리 API")
21+
@RequiredArgsConstructor
22+
@RequestMapping("/api/notification")
23+
@RestController
24+
public class NotificationCommandController {
25+
26+
private final NotificationCommandUseCase notificationCommandUseCase;
27+
28+
@Secured({"ROLE_VOLUNTEER", "ROLE_CENTER"})
29+
@Operation(summary = "알림(1개) 읽음 처리", description = "알림 1개를 읽음 처리합니다.")
30+
@PatchMapping("/read/{notificationId}")
31+
public ApiResponse<String> markSingleNotification(
32+
@CurrentUser UUID userId,
33+
@PathVariable Long notificationId
34+
) {
35+
notificationCommandUseCase.markSingleNotificationAsRead(userId, notificationId);
36+
return ApiResponse.ok("알림 1개 읽음 처리 성공");
37+
}
38+
39+
@Secured({"ROLE_VOLUNTEER", "ROLE_CENTER"})
40+
@Operation(summary = "알림(N개) 읽음 처리", description = "알림 N개를 읽음 처리합니다.")
41+
@PostMapping("/read/multiple")
42+
public ApiResponse<String> markMultipleNotifications(
43+
@CurrentUser UUID userId,
44+
@RequestBody NotificationIdsRequestDto notificationIds
45+
) {
46+
notificationCommandUseCase.markMultipleNotificationsAsRead(userId, notificationIds);
47+
return ApiResponse.ok("알림 N개 읽음 처리 성공");
48+
}
49+
}

0 commit comments

Comments
 (0)