Skip to content

Commit

Permalink
[ feat ] Get simple review infos with type & idByType
Browse files Browse the repository at this point in the history
  • Loading branch information
Minuooooo committed Aug 23, 2023
1 parent fdf6aff commit c297080
Show file tree
Hide file tree
Showing 4 changed files with 145 additions and 74 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@ public class GetReviewListResponseDto {
private int star;
private String content;
private boolean existsFile;
private String type;
private Long idByType;

public static GetReviewListResponseDto toStoreReviewDTO(StoreReview review) {
public static GetReviewListResponseDto from(StoreReview review) {
return GetReviewListResponseDto.builder()
.id(review.getId())
.createdAt(review.getCreatedAt())
Expand All @@ -29,15 +31,39 @@ public static GetReviewListResponseDto toStoreReviewDTO(StoreReview review) {
.existsFile(!review.getStoreReviewImages().isEmpty())
.build();
}
public static GetReviewListResponseDto toProductReviewDTO(ProductReview review) {
public static GetReviewListResponseDto toDetailStoreDto(StoreReview review, String type, Long idByType) {
return GetReviewListResponseDto.builder()
.id(review.getId())
.createdAt(review.getCreatedAt())
.writerEmail(review.getReviewer().getEmail())
.star(review.getStar())
.content(review.getContent())
.existsFile(!review.getProductReviewImages().isEmpty())
.existsFile(!review.getStoreReviewImages().isEmpty())
.type(type)
.idByType(idByType)
.build();
}

}
public static GetReviewListResponseDto from(ProductReview review) {
return GetReviewListResponseDto.builder()
.id(review.getId())
.createdAt(review.getCreatedAt())
.writerEmail(review.getReviewer().getEmail())
.star(review.getStar())
.content(review.getContent())
.existsFile(!review.getProductReviewImages().isEmpty())
.build();
}
public static GetReviewListResponseDto toDetailProductDto(ProductReview review, String type, Long idByType) {
return GetReviewListResponseDto.builder()
.id(review.getId())
.createdAt(review.getCreatedAt())
.writerEmail(review.getReviewer().getEmail())
.star(review.getStar())
.content(review.getContent())
.existsFile(!review.getProductReviewImages().isEmpty())
.type(type)
.idByType(idByType)
.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,16 @@
import org.jetbrains.annotations.NotNull;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.EntityGraph;
import org.springframework.data.jpa.repository.JpaRepository;

public interface ProductReviewRepository extends JpaRepository<ProductReview, Long> {
Page<ProductReview> findProductReviewsByProduct(Pageable pageable,Product product);
@EntityGraph(attributePaths = "product")
Page<ProductReview> findAllByReviewer(Pageable pageable, Member member);
@EntityGraph(attributePaths = "product")
Page<ProductReview> findAllByContentContainingIgnoreCase(String content, Pageable pageable);
@EntityGraph(attributePaths = "product")
@NotNull
Page<ProductReview> findAll(@NotNull Pageable pageable);
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,16 @@
import org.jetbrains.annotations.NotNull;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.EntityGraph;
import org.springframework.data.jpa.repository.JpaRepository;

public interface StoreReviewRepository extends JpaRepository<StoreReview, Long> {
Page<StoreReview> findStoreReviewsByStore(Pageable pageable, Store store);
@EntityGraph(attributePaths = "store")
Page<StoreReview> findAllByReviewer(Pageable pageable, Member member);
@EntityGraph(attributePaths = "store")
Page<StoreReview> findAllByContentContainingIgnoreCase(String content, Pageable pageable);
@EntityGraph(attributePaths = "store")
@NotNull
Page<StoreReview> findAll(@NotNull Pageable pageable);
}
Loading

0 comments on commit c297080

Please sign in to comment.