-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4ecc56a
commit a63b02e
Showing
5 changed files
with
120 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
app/api/user-api/src/main/java/org/example/controller/UserAlarmController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
package org.example.controller; | ||
|
||
import io.swagger.v3.oas.annotations.Operation; | ||
import io.swagger.v3.oas.annotations.tags.Tag; | ||
import java.time.LocalDateTime; | ||
import java.util.List; | ||
import lombok.RequiredArgsConstructor; | ||
import org.example.controller.dto.param.SimpleNotificationApiParam; | ||
import org.example.controller.dto.response.HasUnreadNotificationApiResponse; | ||
import org.example.controller.dto.response.NotificationsApiResponse; | ||
import org.example.security.dto.AuthenticatedInfo; | ||
import org.example.util.DateTimeUtil; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.security.core.annotation.AuthenticationPrincipal; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
@Tag(name = "유저 알림") | ||
@RestController | ||
@RequestMapping("/api/v1/users") | ||
@RequiredArgsConstructor | ||
public class UserAlarmController { | ||
|
||
@GetMapping("/notifications/unread") | ||
@Operation(summary = "안 읽은 알림 존재 여부") | ||
public ResponseEntity<HasUnreadNotificationApiResponse> hasUnreadNotifications( | ||
@AuthenticationPrincipal AuthenticatedInfo info | ||
) { | ||
return ResponseEntity.ok( | ||
HasUnreadNotificationApiResponse.builder() | ||
.hasUnreadNotification(true) | ||
.build() | ||
); | ||
} | ||
|
||
@GetMapping("/notifications") | ||
@Operation(summary = "알림 목록") | ||
public ResponseEntity<NotificationsApiResponse> getNotifications( | ||
@AuthenticationPrincipal AuthenticatedInfo info | ||
) { | ||
return ResponseEntity.ok( | ||
NotificationsApiResponse.builder() | ||
.notifications( | ||
List.of( | ||
SimpleNotificationApiParam.builder() | ||
.title("오하요 고자이마스") | ||
.message("본문 데스") | ||
.notifiedAt(DateTimeUtil.formatDateTime(LocalDateTime.of(2021, 9, 27, 0, 0, 0))) | ||
.showId(java.util.UUID.randomUUID()) | ||
.showImageURL("https://example.com/show.jpg") | ||
.build(), | ||
SimpleNotificationApiParam.builder() | ||
.title("알림알림제목제목알림알림제목제목") | ||
.message("알림본문본문알림본문본문알림본문본문") | ||
.notifiedAt(DateTimeUtil.formatDateTime(LocalDateTime.of(2021, 9, 27, 12, 0, 0))) | ||
.showId(java.util.UUID.randomUUID()) | ||
.showImageURL("https://example.com/show.jpg") | ||
.build(), | ||
SimpleNotificationApiParam.builder() | ||
.title("알림 제목") | ||
.message("알림 본문") | ||
.notifiedAt(DateTimeUtil.formatDateTime(LocalDateTime.of(2021, 9, 27, 23, 0, 0))) | ||
.showId(java.util.UUID.randomUUID()) | ||
.showImageURL("https://example.com/show.jpg") | ||
.build() | ||
) | ||
) | ||
.build() | ||
); | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
...i/user-api/src/main/java/org/example/controller/dto/param/SimpleNotificationApiParam.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package org.example.controller.dto.param; | ||
|
||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import java.util.UUID; | ||
import lombok.Builder; | ||
|
||
@Builder | ||
public record SimpleNotificationApiParam( | ||
@Schema(description = "알림 제목") | ||
String title, | ||
@Schema(description = "알림 본문") | ||
String message, | ||
@Schema(description = "알림 시간") | ||
String notifiedAt, | ||
@Schema(description = "공연 ID") | ||
UUID showId, | ||
@Schema(description = "공연 이미지 URL") | ||
String showImageURL | ||
) { | ||
|
||
} |
12 changes: 12 additions & 0 deletions
12
...i/src/main/java/org/example/controller/dto/response/HasUnreadNotificationApiResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package org.example.controller.dto.response; | ||
|
||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import lombok.Builder; | ||
|
||
@Builder | ||
public record HasUnreadNotificationApiResponse( | ||
@Schema(description = "안 읽은 알림 존재 여부") | ||
boolean hasUnreadNotification | ||
) { | ||
|
||
} |
12 changes: 12 additions & 0 deletions
12
.../user-api/src/main/java/org/example/controller/dto/response/NotificationsApiResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package org.example.controller.dto.response; | ||
|
||
import java.util.List; | ||
import lombok.Builder; | ||
import org.example.controller.dto.param.SimpleNotificationApiParam; | ||
|
||
@Builder | ||
public record NotificationsApiResponse( | ||
List<SimpleNotificationApiParam> notifications | ||
) { | ||
|
||
} |