Skip to content

Commit

Permalink
feat: 리뷰 상세에 키워드, 좋아요 수, 댓글 수 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
korECM committed Nov 5, 2022
1 parent 2086314 commit 0e934c8
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/main/kotlin/zip/cafe/api/dto/Review.kt
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,21 @@ data class ReviewInfo(
val id: Long,
val finalScore: Double,
val description: String,
val visitPurpose : ReviewVisitPurposeInfo,
val visitPurpose: ReviewVisitPurposeInfo,
val foods: List<ReviewFoodInfo>,
val images: List<ReviewImageInfo>,
val keywords: List<ReviewKeywordInfo>,
val likeCount: Long,
val commentCount: Long,
@JsonFormat(pattern = defaultDateFormat)
val createdAt: LocalDateTime,
)

data class ReviewKeywordInfo(
val id: Long,
val keyword: String,
)

data class ReviewVisitPurposeInfo(
val purpose: Purpose,
val score: Int,
Expand Down
3 changes: 3 additions & 0 deletions src/main/kotlin/zip/cafe/service/ReviewService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ class ReviewService(
),
foods = review.foodInfos.map { ReviewFoodInfo(it.food, it.score.score) },
images = review.images.map { ReviewImageInfo(it.id, it.cloudFrontURL) },
keywords = review.cafeKeywords.map { ReviewKeywordInfo(it.id, it.keyword) },
likeCount = review.likeCount,
commentCount = review.commentCount,
createdAt = review.createdAt
),
member = ReviewMemberInfo(
Expand Down
8 changes: 8 additions & 0 deletions src/test/kotlin/zip/cafe/api/ReviewControllerTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ class ReviewControllerTest : WebMvcTestAdapter() {
visitPurpose = ReviewVisitPurposeInfo(purpose = Purpose.DATE, score = 3),
foods = listOf(ReviewFoodInfo(Food.BAKERY, 3), ReviewFoodInfo(Food.COFFEE, 4)),
images = listOf(ReviewImageInfo(1L, "https://image.com/1"), ReviewImageInfo(2L, "https://image.com/2")),
keywords = listOf(ReviewKeywordInfo(1L, "좋은"), ReviewKeywordInfo(2L, "카페")),
likeCount = 3,
commentCount = 2,
createdAt = LocalDateTime.now()
),
member = ReviewMemberInfo(id = memberId, nickname = "길동길동홍길동", profileImageUrl = "https://image.com/123"),
Expand Down Expand Up @@ -67,6 +70,11 @@ class ReviewControllerTest : WebMvcTestAdapter() {
"review.images" type ARRAY means "리뷰에 올라온 이미지 목록",
"review.images[].id" type NUMBER means "리뷰 이미지 id" example reviewDetailInfo.review.images[0].id,
"review.images[].url" type STRING means "리뷰 이미지 url" example reviewDetailInfo.review.images[0].url,
"review.keywords" type ARRAY means "리뷰에 올라온 키워드 목록",
"review.keywords[].id" type NUMBER means "키워드 id" example reviewDetailInfo.review.keywords[0].id,
"review.keywords[].keyword" type STRING means "키워드 이름" example reviewDetailInfo.review.keywords[0].keyword,
"review.likeCount" type NUMBER means "좋아요 수" example reviewDetailInfo.review.likeCount,
"review.commentCount" type NUMBER means "댓글 수" example reviewDetailInfo.review.commentCount,
"review.createdAt" type STRING means "리뷰 작성 시간" example reviewDetailInfo.review.createdAt.formatAsDefault(),
"member.id" type NUMBER means "작성자 id" example reviewDetailInfo.member.id,
"member.nickname" type STRING means "작성자 닉네임" example reviewDetailInfo.member.nickname,
Expand Down

0 comments on commit 0e934c8

Please sign in to comment.