-
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.
refactor: review mapper를 만들어 dto 변환을 처리하자
- Loading branch information
Showing
3 changed files
with
29 additions
and
23 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
26 changes: 26 additions & 0 deletions
26
src/main/kotlin/kr/nagaza/nagazaserver/util/mapper/review/ReviewMapper.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 kr.nagaza.nagazaserver.util.mapper.review | ||
|
||
import kr.nagaza.nagazaserver.domain.model.CafeRoomReview | ||
import kr.nagaza.nagazaserver.domain.model.rating.field.RatingField | ||
import kr.nagaza.nagazaserver.presenter.restapi.dto.response.CafeRoomReviewResponse | ||
import kr.nagaza.nagazaserver.presenter.restapi.dto.response.RatingFieldResponse | ||
|
||
fun RatingField.toDto(): RatingFieldResponse { | ||
return RatingFieldResponse( | ||
ratingFieldType = this.type, | ||
value = this.value, | ||
) | ||
} | ||
|
||
fun CafeRoomReview.toDto(): CafeRoomReviewResponse { | ||
return CafeRoomReviewResponse( | ||
reviewId = this.reviewId, | ||
userId = this.userId, | ||
fields = | ||
this.rating.fields.values.map(RatingField::toDto), | ||
rating = this.rating.sum, | ||
roadType = this.rating.roadType, | ||
createdAt = this.createdAt, | ||
content = this.detail.content, | ||
) | ||
} |