Skip to content

Commit

Permalink
Merge pull request #40 from Route-Box/feature/#39
Browse files Browse the repository at this point in the history
Feature/#39 홈화면 관련 mock up API 추가
  • Loading branch information
suyeoniii authored Aug 9, 2024
2 parents bec4138 + 3008506 commit 29cec27
Show file tree
Hide file tree
Showing 11 changed files with 245 additions and 1 deletion.
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)
}
}
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,
)
}
}
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,
)
}
}
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,
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RequestParam
import org.springframework.web.bind.annotation.RestController

@Tag(name = "루트 관련 API")
@Tag(name = "루트 탐색 관련 API")
@RestController
@Validated
@RequestMapping("/api")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package com.routebox.routebox.controller.route

import com.routebox.routebox.controller.route.dto.GetPopularRoutesResponse
import com.routebox.routebox.controller.route.dto.GetRecommendedRoutesResponse
import com.routebox.routebox.controller.route.dto.PopularRouteDto
import com.routebox.routebox.controller.route.dto.RecommendRouteDto
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

@Tag(name = "홈 - 루트 관련 API")
@RestController
@Validated
@RequestMapping("/api")
class RouteHomeController {
@Operation(
summary = "추천 루트 조회",
description = "추천 루트 조회",
)
@ApiResponses(
ApiResponse(responseCode = "200"),
)
@GetMapping("/v1/routes/recommend")
fun getRecommendedRoutes(): GetRecommendedRoutesResponse {
val comment = "8월엔 여기로 여행 어때요?"
val mockData = listOf(
RecommendRouteDto.from(1, "경주 200% 즐기는 법", "경주 200% 즐기는 법", "https://routebox-resources.s3.ap-northeast-2.amazonaws.com/image/1.jpg"),
RecommendRouteDto.from(2, "대구 먹방 여행", "대구 200% 즐기는 법", "https://routebox-resources.s3.ap-northeast-2.amazonaws.com/image/2.jpg"),
RecommendRouteDto.from(3, "대전 빵 여행", "대전 200% 즐기는 법", "https://routebox-resources.s3.ap-northeast-2.amazonaws.com/image/3.jpg"),
)
return GetRecommendedRoutesResponse.from(comment, mockData)
}

@Operation(
summary = "인기 루트 조회",
description = "인기 루트 조회",
)
@ApiResponses(
ApiResponse(responseCode = "200"),
)
@GetMapping("/v1/routes/popular")
fun getPopularRoutes(): GetPopularRoutesResponse {
val mockData = listOf(
PopularRouteDto(1, "8월에 꼭 가야하는 장소"),
PopularRouteDto(2, "여자친구에게 칭찬 왕창 받은 데이트 코스"),
PopularRouteDto(3, "친구들과 함께 떠나고 싶은 여행지"),
)
return GetPopularRoutesResponse.from(mockData)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.routebox.routebox.controller.route.dto

import io.swagger.v3.oas.annotations.media.Schema

data class GetPopularRoutesResponse(
@Schema(description = "인기 루트 목록")
val routes: List<PopularRouteDto>,
) {
companion object {
fun from(routes: List<PopularRouteDto>): GetPopularRoutesResponse = GetPopularRoutesResponse(
routes = routes,
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.routebox.routebox.controller.route.dto

import io.swagger.v3.oas.annotations.media.Schema

data class GetRecommendedRoutesResponse(
@Schema(description = "오늘의 추천루트 문구")
val comment: String,

@Schema(description = "추천 루트 목록")
val routes: List<RecommendRouteDto>,
) {
companion object {
fun from(comment: String, routes: List<RecommendRouteDto>): GetRecommendedRoutesResponse = GetRecommendedRoutesResponse(
comment = comment,
routes = routes,
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.routebox.routebox.controller.route.dto

import io.swagger.v3.oas.annotations.media.Schema

data class PopularRouteDto(
@Schema(description = "루트 ID")
val id: Long,

@Schema(description = "루트 이름")
val name: String,
) {
companion object {
fun from(id: Long, name: String): PopularRouteDto = PopularRouteDto(
id = id,
name = name,
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.routebox.routebox.controller.route.dto

import io.swagger.v3.oas.annotations.media.Schema

data class RecommendRouteDto(
@Schema(description = "루트 ID")
val id: Long,

@Schema(description = "루트 이름")
val routeName: String,

@Schema(description = "루트 설명")
val routeDescription: String,

@Schema(description = "루트 대표 이미지")
val routeImageUrl: String,
) {
companion object {
fun from(id: Long, routeName: String, routeDescription: String, routeImageUrl: String): RecommendRouteDto = RecommendRouteDto(
id = id,
routeName = routeName,
routeDescription = routeDescription,
routeImageUrl = routeImageUrl,
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ class SecurityConfig {
"/api/v1/users/nickname/*/availability" to HttpMethod.GET,
"/api/v1/routes" to HttpMethod.GET,
"/api/v1/routes/*" to HttpMethod.GET,
"/api/v1/notifications" to HttpMethod.GET,
"/api/v1/notifications/unread" to HttpMethod.GET,
)

@Bean
Expand Down

0 comments on commit 29cec27

Please sign in to comment.