Skip to content

Commit

Permalink
Merge pull request #30 from MARKETFUBY/revert-29-feat/product-detail
Browse files Browse the repository at this point in the history
Revert "[차소연] 상품 상세 조회에서 각 리뷰의 이미지 리스트 추가"
  • Loading branch information
Soyeon-Cha authored Nov 26, 2023
2 parents 44c0e59 + 57292c0 commit 9b2e1e2
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 16 deletions.
7 changes: 2 additions & 5 deletions src/main/java/MARKETFUBY/Product/dto/ProductReviewDto.java
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
package MARKETFUBY.Product.dto;

import MARKETFUBY.Review.domain.Review;
import MARKETFUBY.ReviewImage.domain.ReviewImage;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;

import java.time.LocalDate;
import java.util.List;

@Getter
@Builder
Expand All @@ -19,18 +17,17 @@ public class ProductReviewDto {
private String brand;
private String title;
private String content;
private List<ReviewImage> imageList;
// private String imgUrl;
private LocalDate date;
private Boolean isReviewHelp;

public static ProductReviewDto from(Review review, List<ReviewImage> images, Boolean isReviewHelp){
public static ProductReviewDto from(Review review, Boolean isReviewHelp){
return ProductReviewDto.builder()
.name(review.getWriter().getName())
.level(review.getWriter().getLevel())
.brand(review.getProduct().getBrand())
.title(review.getProduct().getTitle())
.content(review.getContent())
.imageList(images)
.date(review.getCreatedAt().toLocalDate())
.isReviewHelp(isReviewHelp)
.build();
Expand Down
10 changes: 2 additions & 8 deletions src/main/java/MARKETFUBY/Product/service/ProductService.java
Original file line number Diff line number Diff line change
Expand Up @@ -237,25 +237,19 @@ public List<ProductReviewDto> findReviewsByProduct(Product product, Long memberI
List<Review> reviewList = reviewRepository.findAllByProduct(product);
List<ProductReviewDto> productReviewDtos = new ArrayList<>();
reviewList.forEach(review -> {
List<ReviewImage> images = findImagesByReview(review);
Member member = memberRepository.findByMemberId(memberId);
if (member != null) {
Boolean isReviewHelp = reviewHelpRepository.existsByMemberAndReview(member, review);
ProductReviewDto productReviewDto = ProductReviewDto.from(review, images, isReviewHelp);
ProductReviewDto productReviewDto = ProductReviewDto.from(review, isReviewHelp);
productReviewDtos.add(productReviewDto);
} else {
ProductReviewDto productReviewDto = ProductReviewDto.from(review, images, false);
ProductReviewDto productReviewDto = ProductReviewDto.from(review, false);
productReviewDtos.add(productReviewDto);
}
});
return productReviewDtos;
}

public List<ReviewImage> findImagesByReview(Review review){
List<ReviewImage> imageList = reviewImageRepository.findAllByReview(review);
return imageList;
}

public List<ProductInquiryDto> findInquiriesByProduct(Product product){
List<Inquiry> inquiryList = inquiryRepository.findAllByProduct(product);
List<ProductInquiryDto> productInquiryDtos = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ public class ReviewImage {
@Column(name = "image_id", updatable = false)
private Long imageId;

@Getter
@ManyToOne
@JoinColumn(name = "review_id", nullable = false)
private Review review;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import MARKETFUBY.Inquiry.domain.Inquiry;
import MARKETFUBY.Product.domain.Product;
import MARKETFUBY.Review.domain.Review;
import org.springframework.data.jpa.repository.JpaRepository;

import MARKETFUBY.ReviewImage.domain.ReviewImage;
Expand All @@ -11,5 +10,4 @@

public interface ReviewImageRepository extends JpaRepository<ReviewImage, Long> {
List<ReviewImage> findAllByProduct(Product product);
List<ReviewImage> findAllByReview(Review review);
}

0 comments on commit 9b2e1e2

Please sign in to comment.