-
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
Showing
5 changed files
with
113 additions
and
0 deletions.
There are no files selected for viewing
57 changes: 57 additions & 0 deletions
57
src/main/kotlin/com/routebox/routebox/controller/notification/NotificationController.kt
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,57 @@ | ||
package com.routebox.routebox.controller.notification | ||
|
||
import com.routebox.routebox.controller.notification.dto.GetNotificationHistoryResponse | ||
import com.routebox.routebox.controller.notification.dto.GetUnreadNotificationResponse | ||
import com.routebox.routebox.controller.notification.dto.NotificationHistoryDto | ||
import io.swagger.v3.oas.annotations.Operation | ||
import io.swagger.v3.oas.annotations.responses.ApiResponse | ||
import io.swagger.v3.oas.annotations.responses.ApiResponses | ||
import io.swagger.v3.oas.annotations.tags.Tag | ||
import org.springframework.validation.annotation.Validated | ||
import org.springframework.web.bind.annotation.GetMapping | ||
import org.springframework.web.bind.annotation.RequestMapping | ||
import org.springframework.web.bind.annotation.RestController | ||
import kotlin.random.Random | ||
|
||
@Tag(name = "알림 관련 API") | ||
@RestController | ||
@Validated | ||
@RequestMapping("/api") | ||
class NotificationController { | ||
@Operation( | ||
summary = "알림 내역 조회", | ||
description = "알림 내역 조회", | ||
) | ||
@ApiResponses( | ||
ApiResponse(responseCode = "200"), | ||
) | ||
@GetMapping("/v1/notifications") | ||
fun getNotificationHistory(): GetNotificationHistoryResponse { | ||
val mockData = listOf( | ||
NotificationHistoryDto.from(1, "알림 내용1", "2024-08-04", false), | ||
NotificationHistoryDto.from(2, "알림 내용2", "2024-08-03", false), | ||
NotificationHistoryDto.from(3, "알림 내용3", "2024-08-02", true), | ||
NotificationHistoryDto.from(4, "알림 내용4", "2024-08-02", true), | ||
NotificationHistoryDto.from(5, "알림 내용5", "2024-08-01", true), | ||
NotificationHistoryDto.from(6, "알림 내용6", "2024-08-01", true), | ||
NotificationHistoryDto.from(7, "알림 내용7", "2024-08-01", true), | ||
NotificationHistoryDto.from(8, "알림 내용8", "2024-07-31", true), | ||
NotificationHistoryDto.from(9, "알림 내용9", "2024-07-30", true), | ||
NotificationHistoryDto.from(10, "알림 내용10", "2024-07-20", true), | ||
) | ||
return GetNotificationHistoryResponse.from(mockData) | ||
} | ||
|
||
@Operation( | ||
summary = "안읽은 알림 여부 조회", | ||
description = "안읽은 알림 여부 조회", | ||
) | ||
@ApiResponses( | ||
ApiResponse(responseCode = "200"), | ||
) | ||
@GetMapping("/v1/notifications/unread") | ||
fun checkUnreadNotifications(): GetUnreadNotificationResponse { | ||
val mockData: Boolean = Random.nextBoolean() | ||
return GetUnreadNotificationResponse.from(mockData) | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
...otlin/com/routebox/routebox/controller/notification/dto/GetNotificationHistoryResponse.kt
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,14 @@ | ||
package com.routebox.routebox.controller.notification.dto | ||
|
||
import io.swagger.v3.oas.annotations.media.Schema | ||
|
||
data class GetNotificationHistoryResponse( | ||
@Schema(description = "알림 목록") | ||
val notifications: List<NotificationHistoryDto>, | ||
) { | ||
companion object { | ||
fun from(notifications: List<NotificationHistoryDto>): GetNotificationHistoryResponse = GetNotificationHistoryResponse( | ||
notifications = notifications, | ||
) | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
...kotlin/com/routebox/routebox/controller/notification/dto/GetUnreadNotificationResponse.kt
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,14 @@ | ||
package com.routebox.routebox.controller.notification.dto | ||
|
||
import io.swagger.v3.oas.annotations.media.Schema | ||
|
||
data class GetUnreadNotificationResponse( | ||
@Schema(description = "읽지 않은 알림 존재 여부") | ||
val hasUnreadNotification: Boolean, | ||
) { | ||
companion object { | ||
fun from(hasUnreadNotification: Boolean): GetUnreadNotificationResponse = GetUnreadNotificationResponse( | ||
hasUnreadNotification = hasUnreadNotification, | ||
) | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
src/main/kotlin/com/routebox/routebox/controller/notification/dto/NotificationHistoryDto.kt
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,26 @@ | ||
package com.routebox.routebox.controller.notification.dto | ||
|
||
import io.swagger.v3.oas.annotations.media.Schema | ||
|
||
data class NotificationHistoryDto( | ||
@Schema(description = "알림 ID") | ||
val id: Long, | ||
|
||
@Schema(description = "알림 내용") | ||
val content: String, | ||
|
||
@Schema(description = "알림 생성일자 (yyyy-MM-dd)") | ||
val date: String, | ||
|
||
@Schema(description = "알림 읽음 여부") | ||
val isRead: Boolean, | ||
) { | ||
companion object { | ||
fun from(id: Long, content: String, date: String, isRead: Boolean): NotificationHistoryDto = NotificationHistoryDto( | ||
id = id, | ||
content = content, | ||
date = date, | ||
isRead = isRead, | ||
) | ||
} | ||
} |
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