Skip to content

Commit

Permalink
fix: 리뷰 생성 후 멤버 정보 리턴 로직 변경 (#97)
Browse files Browse the repository at this point in the history
  • Loading branch information
EunjiShin authored Aug 1, 2024
1 parent cb92b12 commit 16105c2
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,6 @@ public BaseReviewResponse create(
@RequestBody @Valid CreateReviewRequest request) {
CreateReviewUsecase.CreateReviewResult result =
createReviewUsecase.create(blockId, seatNumber, memberId, request.toCommand());
return BaseReviewResponse.from(result.review());
return BaseReviewResponse.from(result);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import org.depromeet.spot.domain.seat.Seat;
import org.depromeet.spot.domain.section.Section;
import org.depromeet.spot.domain.stadium.Stadium;
import org.depromeet.spot.usecase.port.in.review.CreateReviewUsecase.CreateReviewResult;

public record BaseReviewResponse(
Long id,
Expand All @@ -26,6 +27,34 @@ public record BaseReviewResponse(
List<ReviewImageResponse> images,
List<KeywordResponse> keywords) {

public static BaseReviewResponse from(CreateReviewResult result) {
Review review = result.review();
Member member = result.member();
Seat seat = result.seat();
return new BaseReviewResponse(
review.getId(),
MemberInfo.from(member),
StadiumResponse.from(review.getStadium()),
SectionResponse.from(review.getSection()),
BlockResponse.from(review.getBlock()),
RowResponse.from(review.getRow()),
SeatResponse.from(seat),
review.getDateTime(),
review.getContent(),
review.getImages().stream().map(ReviewImageResponse::from).toList(),
review.getKeywords().stream()
.map(
reviewKeyword -> {
Keyword keyword =
review.getKeywordById(reviewKeyword.getKeywordId());
return new KeywordResponse(
reviewKeyword.getId(),
keyword.getContent(),
keyword.getIsPositive());
})
.toList());
}

public static BaseReviewResponse from(Review review) {
return new BaseReviewResponse(
review.getId(),
Expand Down

0 comments on commit 16105c2

Please sign in to comment.