-
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
14 changed files
with
170 additions
and
148 deletions.
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
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
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
18 changes: 0 additions & 18 deletions
18
.../kotlin/kr/nagaza/nagazaserver/infrastructure/jpa/entity/CafeRoomReviewDetailOptEntity.kt
This file was deleted.
Oops, something went wrong.
33 changes: 5 additions & 28 deletions
33
src/main/kotlin/kr/nagaza/nagazaserver/infrastructure/jpa/entity/CafeRoomReviewEntity.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 |
---|---|---|
@@ -1,46 +1,23 @@ | ||
package kr.nagaza.nagazaserver.infrastructure.jpa.entity | ||
|
||
import jakarta.persistence.* | ||
import kr.nagaza.nagazaserver.domain.model.CafeRoomReview | ||
import java.util.* | ||
|
||
@Entity(name = "cafe_room_review") | ||
class CafeRoomReviewEntity( | ||
@Id | ||
@Column(name = "review_id") | ||
val reviewId: String, | ||
|
||
@Column(name = "room_id") | ||
val roomId: String, | ||
|
||
@Column(name = "user_id") | ||
val userId: String, | ||
|
||
@Column(name = "content") | ||
val content: String, | ||
|
||
@OneToOne | ||
@PrimaryKeyJoinColumn | ||
val detail: CafeRoomReviewDetailEntity, | ||
|
||
@OneToMany(fetch = FetchType.LAZY) | ||
@JoinColumn(name = "review_id") | ||
val reviewOpts: MutableSet<CafeRoomReviewDetailOptEntity> = mutableSetOf(), | ||
) { | ||
fun toModel() = CafeRoomReview( | ||
reviewId = reviewId, | ||
roomId = roomId, | ||
userId = userId, | ||
content = content, | ||
detail = detail.toModel(), | ||
) | ||
|
||
companion object { | ||
fun fromModel(model: CafeRoomReview) = CafeRoomReviewEntity( | ||
reviewId = model.reviewId, | ||
roomId = model.roomId, | ||
userId = model.userId, | ||
content = model.content, | ||
detail = CafeRoomReviewDetailEntity.fromModel(model.detail), | ||
) | ||
} | ||
} | ||
val ratingFields: List<CafeRoomReviewRatingFieldEntity> = listOf(), | ||
@Column(name = "created_at") | ||
val createdAt: Date, | ||
) |
19 changes: 19 additions & 0 deletions
19
...otlin/kr/nagaza/nagazaserver/infrastructure/jpa/entity/CafeRoomReviewRatingFieldEntity.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,19 @@ | ||
package kr.nagaza.nagazaserver.infrastructure.jpa.entity | ||
|
||
import jakarta.persistence.Column | ||
import jakarta.persistence.Entity | ||
import jakarta.persistence.Id | ||
import kr.nagaza.nagazaserver.domain.model.rating.field.RatingFieldType | ||
|
||
@Entity(name = "cafe_room_review_rating_field") | ||
class CafeRoomReviewRatingFieldEntity( | ||
@Id | ||
@Column(name = "rating_field_id") | ||
val ratingFieldId: String, | ||
@Column(name = "review_id") | ||
val reviewId: String, | ||
@Column(name = "type") | ||
val fieldType: RatingFieldType, | ||
@Column(name = "value") | ||
val value: Int, | ||
) |
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
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
39 changes: 35 additions & 4 deletions
39
...in/kotlin/kr/nagaza/nagazaserver/presenter/restapi/controller/CafeRoomReviewController.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 |
---|---|---|
@@ -1,17 +1,48 @@ | ||
package kr.nagaza.nagazaserver.presenter.restapi.controller | ||
|
||
import kr.nagaza.nagazaserver.domain.model.rating.Rating | ||
import kr.nagaza.nagazaserver.domain.service.CafeRoomReviewService | ||
import kr.nagaza.nagazaserver.presenter.restapi.api.CafeRoomReviewApi | ||
import kr.nagaza.nagazaserver.presenter.restapi.dto.response.CafeRoomReviewListResponse | ||
import kr.nagaza.nagazaserver.presenter.restapi.dto.response.CafeRoomReviewResponse | ||
import kr.nagaza.nagazaserver.presenter.restapi.dto.response.RatingFieldResponse | ||
import org.springframework.stereotype.Controller | ||
|
||
@Controller | ||
class CafeRoomReviewController( | ||
private val cafeRoomReviewService: CafeRoomReviewService, | ||
) : CafeRoomReviewApi { | ||
override fun getReviews(cafeId: String, roomId: String): List<CafeRoomReviewResponse> { | ||
return cafeRoomReviewService.getAllByRoomId( | ||
roomId = roomId, | ||
).map(CafeRoomReviewResponse::fromModel) | ||
override fun getReviews( | ||
cafeId: String, | ||
roomId: String, | ||
): CafeRoomReviewListResponse { | ||
val reviewList = | ||
cafeRoomReviewService.getAllByRoomId( | ||
roomId = roomId, | ||
) | ||
|
||
return CafeRoomReviewListResponse( | ||
reviewCount = reviewList.size, | ||
rating = reviewList.map { it.rating.sum }.average(), | ||
roadType = Rating.getRoadType(reviewList.map { it.rating.sum }.average()), | ||
reviewList = | ||
reviewList.map { | ||
CafeRoomReviewResponse( | ||
reviewId = it.reviewId, | ||
userId = it.userId, | ||
fields = | ||
it.rating.fields.map { field -> | ||
RatingFieldResponse( | ||
ratingFieldType = field.key, | ||
value = field.value.value, | ||
) | ||
}, | ||
rating = it.rating.sum, | ||
roadType = Rating.getRoadType(it.rating.sum), | ||
createdAt = it.createdAt, | ||
content = it.detail.content, | ||
) | ||
}, | ||
) | ||
} | ||
} |
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
Oops, something went wrong.