Skip to content

Commit

Permalink
refactor: myReview에서 상품명, 수정날짜 받게 설정
Browse files Browse the repository at this point in the history
  • Loading branch information
youcastle03 committed Nov 14, 2024
1 parent 0de2247 commit 0d9ea91
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 5 deletions.
3 changes: 2 additions & 1 deletion src/main/java/jeje/work/aeatbe/dto/review/ReviewDTO.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package jeje.work.aeatbe.dto.review;

import jakarta.annotation.Nullable;
import java.time.LocalDateTime;
import lombok.Builder;

@Builder
Expand All @@ -10,7 +11,7 @@ public record ReviewDTO(
String content,
Long userId,
Long productId,

LocalDateTime date,
@Nullable
String productImgUrl) {
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package jeje.work.aeatbe.dto.review;

import java.time.LocalDateTime;
import jeje.work.aeatbe.dto.user.UserInfoResponseDTO;
import lombok.Builder;

Expand All @@ -10,6 +11,8 @@ public record ReviewResponseDTO(
String content,
UserInfoResponseDTO user,
Long productId,
String productImgUrl
String productImgUrl,
String productName,
LocalDateTime date
) {
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public ReviewDTO toDTO(Review review) {
.userId(review.getUser().getId())
.productId(review.getProduct().getId())
.productImgUrl(review.getProduct().getProductImageUrl())
.date(review.getUpdatedAt())
.build();
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
package jeje.work.aeatbe.mapper.Review;

import jeje.work.aeatbe.dto.product.ProductDTO;
import jeje.work.aeatbe.dto.review.ReviewDTO;
import jeje.work.aeatbe.dto.review.ReviewResponseDTO;
import jeje.work.aeatbe.dto.user.UserInfoResponseDTO;
import org.springframework.stereotype.Component;

@Component
public class ReviewResponseMapper {
public ReviewResponseDTO toDTO(ReviewDTO reviewDTO, UserInfoResponseDTO userInfoResponseDTO) {
public ReviewResponseDTO toDTO(ReviewDTO reviewDTO, UserInfoResponseDTO userInfoResponseDTO, ProductDTO productDto) {
return ReviewResponseDTO.builder()
.id(reviewDTO.id())
.rate(reviewDTO.rate())
.content(reviewDTO.content())
.user(userInfoResponseDTO)
.productId(reviewDTO.productId())
.productImgUrl(reviewDTO.productImgUrl())
.productImgUrl(productDto.productImageUrl())
.date(reviewDTO.date())
.build();
}
}
3 changes: 2 additions & 1 deletion src/main/java/jeje/work/aeatbe/service/ReviewService.java
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ protected List<Review> getReviewEntitiesByUser(Long userId) {
*/
public ReviewResponseDTO getReviewResponseDTO(ReviewDTO review) {
var userDTO = userService.getUserInfo(review.userId());
return reviewResponseMapper.toDTO(review, userDTO);
var productDTO = productService.getProductDTO(review.productId());
return reviewResponseMapper.toDTO(review, userDTO, productDTO);
}

/**
Expand Down

0 comments on commit 0d9ea91

Please sign in to comment.