diff --git a/src/main/java/com/jeju/nanaland/domain/review/dto/ReviewResponse.java b/src/main/java/com/jeju/nanaland/domain/review/dto/ReviewResponse.java index 6795a450..197bbd80 100644 --- a/src/main/java/com/jeju/nanaland/domain/review/dto/ReviewResponse.java +++ b/src/main/java/com/jeju/nanaland/domain/review/dto/ReviewResponse.java @@ -1,6 +1,5 @@ package com.jeju.nanaland.domain.review.dto; -import com.jeju.nanaland.domain.common.data.Category; import com.jeju.nanaland.domain.common.dto.ImageFileDto; import com.jeju.nanaland.domain.common.entity.ImageFile; import com.jeju.nanaland.domain.review.entity.ReviewTypeKeyword; @@ -172,8 +171,8 @@ public static class MemberReviewDetailDto { private Long id; @Schema(description = "장소 게시물 id") private Long postId; - @Schema(description = "장소 카테고리(이색체험, 맛집)") - private Category category; + @Schema(description = "장소 카테고리(문화예술, 이색체험, 맛집)") + private String category; @Schema(description = "장소명") private String placeName; @Schema(description = "리뷰 점수") @@ -192,7 +191,7 @@ public static class MemberReviewDetailDto { private Set reviewTypeKeywords; @QueryProjection - public MemberReviewDetailDto(Long id, Long postId, Category category, + public MemberReviewDetailDto(Long id, Long postId, String category, Integer rating, String content, LocalDateTime createdAt, Long heartCount, boolean isReviewHeart) { this.id = id; @@ -206,6 +205,13 @@ public MemberReviewDetailDto(Long id, Long postId, Category category, } } + @Getter + @AllArgsConstructor + public static class ExperienceInfo { + private String title; + private String experienceType; + } + @Getter @Builder @Schema(description = "회원이 작성한 리뷰 리스트 미리보기 정보") @@ -227,8 +233,8 @@ public static class MemberReviewPreviewDetailDto { private Long id; @Schema(description = "장소 게시물 id") private Long postId; - @Schema(description = "장소 카테고리(이색체험, 맛집)") - private Category category; + @Schema(description = "장소 카테고리(액티비티, 문화예술, 맛집)") + private String category; @Schema(description = "장소명") private String placeName; @Schema(description = "리뷰 작성일") @@ -239,7 +245,7 @@ public static class MemberReviewPreviewDetailDto { private ImageFileDto imageFileDto; @QueryProjection - public MemberReviewPreviewDetailDto(Long id, Long postId, Category category, + public MemberReviewPreviewDetailDto(Long id, Long postId, String category, LocalDateTime createdAt, Long heartCount) { this.id = id; this.postId = postId; diff --git a/src/main/java/com/jeju/nanaland/domain/review/repository/ReviewRepositoryImpl.java b/src/main/java/com/jeju/nanaland/domain/review/repository/ReviewRepositoryImpl.java index 6dd57c02..72225688 100644 --- a/src/main/java/com/jeju/nanaland/domain/review/repository/ReviewRepositoryImpl.java +++ b/src/main/java/com/jeju/nanaland/domain/review/repository/ReviewRepositoryImpl.java @@ -23,6 +23,7 @@ import com.jeju.nanaland.domain.review.dto.QReviewResponse_MemberReviewPreviewDetailDto; import com.jeju.nanaland.domain.review.dto.QReviewResponse_MyReviewDetailDto; import com.jeju.nanaland.domain.review.dto.QReviewResponse_ReviewDetailDto; +import com.jeju.nanaland.domain.review.dto.ReviewResponse.ExperienceInfo; import com.jeju.nanaland.domain.review.dto.ReviewResponse.MemberReviewDetailDto; import com.jeju.nanaland.domain.review.dto.ReviewResponse.MemberReviewPreviewDetailDto; import com.jeju.nanaland.domain.review.dto.ReviewResponse.MyReviewDetailDto; @@ -30,6 +31,7 @@ import com.jeju.nanaland.domain.review.entity.ReviewTypeKeyword; import com.querydsl.core.group.GroupBy; import com.querydsl.core.types.ExpressionUtils; +import com.querydsl.core.types.Projections; import com.querydsl.core.types.dsl.BooleanExpression; import com.querydsl.jpa.JPAExpressions; import com.querydsl.jpa.JPQLQuery; @@ -203,7 +205,7 @@ public Page findReviewListByMember(Long currentMemberId, .select(new QReviewResponse_MemberReviewDetailDto( review.id, review.post.id, - review.category, + review.category.stringValue(), review.rating, review.content, review.createdAt, @@ -230,14 +232,14 @@ public Page findReviewListByMember(Long currentMemberId, // 2. EXPERIENCE 카테고리의 리뷰에 대한 제목 조회 List experienceIds = resultDto.stream() - .filter(dto -> dto.getCategory() == Category.EXPERIENCE) + .filter(dto -> dto.getCategory().equals(Category.EXPERIENCE.name())) .map(MemberReviewDetailDto::getPostId) .toList(); - Map experienceTitleMap = fetchExperienceTitles(experienceIds, language); + Map experienceTitleAndTypeMap = fetchExperienceTitlesAndTypes(experienceIds, language); // 3. RESTAURANT 카테고리의 리뷰에 대한 제목 조회 List restaurantIds = resultDto.stream() - .filter(dto -> dto.getCategory() == Category.RESTAURANT) + .filter(dto -> dto.getCategory().equals(Category.RESTAURANT.name())) .map(MemberReviewDetailDto::getPostId) .toList(); Map restaurantTitleMap = fetchRestaurantTitles(restaurantIds, language); @@ -255,14 +257,15 @@ public Page findReviewListByMember(Long currentMemberId, // 추가 정보를 리뷰 DTO에 설정 resultDto.forEach( reviewDetailDto -> { + String category = reviewDetailDto.getCategory(); // 제목 설정 - if (reviewDetailDto.getCategory() == Category.EXPERIENCE) { - reviewDetailDto.setPlaceName( - experienceTitleMap.getOrDefault(reviewDetailDto.getPostId(), "") - ); + if (category.equals(Category.EXPERIENCE.name())) { + ExperienceInfo experienceInfo = experienceTitleAndTypeMap.get(reviewDetailDto.getPostId()); + reviewDetailDto.setPlaceName(experienceInfo.getTitle()); + reviewDetailDto.setCategory(experienceInfo.getExperienceType()); } - if (reviewDetailDto.getCategory() == Category.RESTAURANT) { + else if (category.equals(Category.RESTAURANT.name())) { reviewDetailDto.setPlaceName( restaurantTitleMap.getOrDefault(reviewDetailDto.getPostId(), "") ); @@ -303,7 +306,7 @@ public List findReviewPreviewByMember(Long current .select(new QReviewResponse_MemberReviewPreviewDetailDto( review.id, review.post.id, - review.category, + review.category.stringValue(), review.createdAt, // 해당 리뷰의 좋아요 개수 ExpressionUtils.as(getHeartCountQuery(), "heartCount") @@ -325,14 +328,14 @@ public List findReviewPreviewByMember(Long current // 2. EXPERIENCE 카테고리의 리뷰에 대한 제목 조회 List experienceIds = resultDto.stream() - .filter(dto -> dto.getCategory() == Category.EXPERIENCE) + .filter(dto -> dto.getCategory().equals(Category.EXPERIENCE.name())) .map(MemberReviewPreviewDetailDto::getPostId) .toList(); - Map experienceTitleMap = fetchExperienceTitles(experienceIds, language); + Map experienceTitleAndTypeMap = fetchExperienceTitlesAndTypes(experienceIds, language); // 3. RESTAURANT 카테고리의 리뷰에 대한 제목 조회 List restaurantIds = resultDto.stream() - .filter(dto -> dto.getCategory() == Category.RESTAURANT) + .filter(dto -> dto.getCategory().equals(Category.RESTAURANT.name())) .map(MemberReviewPreviewDetailDto::getPostId) .toList(); Map restaurantTitleMap = fetchRestaurantTitles(restaurantIds, language); @@ -349,13 +352,13 @@ public List findReviewPreviewByMember(Long current reviewImageMap.getOrDefault(reviewDetailDto.getId(), null)); // 제목 설정 - if (reviewDetailDto.getCategory() == Category.EXPERIENCE) { - reviewDetailDto.setPlaceName( - experienceTitleMap.getOrDefault(reviewDetailDto.getPostId(), "") - ); + if (reviewDetailDto.getCategory().equals(Category.EXPERIENCE.name())) { + ExperienceInfo experienceInfo = experienceTitleAndTypeMap.get(reviewDetailDto.getPostId()); + reviewDetailDto.setPlaceName(experienceInfo.getTitle()); + reviewDetailDto.setCategory(experienceInfo.getExperienceType()); } - if (reviewDetailDto.getCategory() == Category.RESTAURANT) { + if (reviewDetailDto.getCategory().equals(Category.RESTAURANT.name())) { reviewDetailDto.setPlaceName( restaurantTitleMap.getOrDefault(reviewDetailDto.getPostId(), "") ); @@ -441,17 +444,21 @@ private Map fetchReviewImages(List reviewIds) { } // EXPERIENCE 카테고리의 리뷰 제목 조회 - private Map fetchExperienceTitles(List experienceIds, + private Map fetchExperienceTitlesAndTypes(List experienceIds, Language language) { return queryFactory - .select(experienceTrans.title) + .select(Projections.constructor(ExperienceInfo.class, + experienceTrans.title, + experience.experienceType.stringValue())) .from(experience) .innerJoin(experience.experienceTrans, experienceTrans) .where(experience.id.in(experienceIds) .and(experienceTrans.language.eq(language))) .transform(GroupBy.groupBy(experience.id) - .as(experienceTrans.title)); + .as(Projections.constructor(ExperienceInfo.class, + experienceTrans.title, + experience.experienceType.stringValue()))); } // RESTAURANT 카테고리의 리뷰 제목 조회 diff --git a/src/test/java/com/jeju/nanaland/domain/review/repository/ReviewRepositoryImplTest.java b/src/test/java/com/jeju/nanaland/domain/review/repository/ReviewRepositoryImplTest.java index 50debe0c..fbc8b30b 100644 --- a/src/test/java/com/jeju/nanaland/domain/review/repository/ReviewRepositoryImplTest.java +++ b/src/test/java/com/jeju/nanaland/domain/review/repository/ReviewRepositoryImplTest.java @@ -9,6 +9,7 @@ import com.jeju.nanaland.domain.common.entity.Post; import com.jeju.nanaland.domain.experience.entity.Experience; import com.jeju.nanaland.domain.experience.entity.ExperienceTrans; +import com.jeju.nanaland.domain.experience.entity.enums.ExperienceType; import com.jeju.nanaland.domain.member.dto.MemberResponse.MemberInfoDto; import com.jeju.nanaland.domain.member.entity.Member; import com.jeju.nanaland.domain.member.entity.enums.Provider; @@ -101,6 +102,7 @@ private Experience createExperience() { Experience experience = Experience.builder() .firstImageFile(imageFile) .priority((long) 1) + .experienceType(ExperienceType.ACTIVITY) .build(); entityManager.persistAndFlush(experience); ExperienceTrans experienceTrans = ExperienceTrans.builder() @@ -228,7 +230,7 @@ void findReviewListByMember() { MemberReviewDetailDto dto = memberReviewDetails.getContent().get(0); assertThat(dto.getId()).isNotNull(); assertThat(dto.getPostId()).isEqualTo(experience.getId()); - assertThat(dto.getCategory()).isEqualTo(Category.EXPERIENCE); + assertThat(dto.getCategory()).isEqualTo(ExperienceType.ACTIVITY.name()); assertThat(dto.getPlaceName()).isEqualTo("experience title"); } @@ -247,7 +249,7 @@ void findReviewListByMember2() { MemberReviewDetailDto dto = memberReviewDetails.getContent().get(0); assertThat(dto.getId()).isNotNull(); assertThat(dto.getPostId()).isEqualTo(experience2.getId()); - assertThat(dto.getCategory()).isEqualTo(Category.EXPERIENCE); + assertThat(dto.getCategory()).isEqualTo(ExperienceType.ACTIVITY.name()); assertThat(dto.getPlaceName()).isEqualTo("experience title"); } @@ -267,7 +269,7 @@ void findReviewListByMember3() { MemberReviewDetailDto dto = memberReviewDetails.getContent().get(0); assertThat(dto.getId()).isNotNull(); assertThat(dto.getPostId()).isEqualTo(experience2.getId()); - assertThat(dto.getCategory()).isEqualTo(Category.EXPERIENCE); + assertThat(dto.getCategory()).isEqualTo(ExperienceType.ACTIVITY.name()); assertThat(dto.getPlaceName()).isEqualTo("experience title"); } @@ -298,7 +300,7 @@ void findReviewPreviewByMember() { MemberReviewPreviewDetailDto dto = memberReviewPreviewDetails.get(0); assertThat(dto.getId()).isNotNull(); assertThat(dto.getPostId()).isEqualTo(experience.getId()); - assertThat(dto.getCategory()).isEqualTo(Category.EXPERIENCE); + assertThat(dto.getCategory()).isEqualTo(ExperienceType.ACTIVITY.name()); assertThat(dto.getPlaceName()).isEqualTo("experience title"); } @@ -314,7 +316,7 @@ void findReviewPreviewByMember2() { MemberReviewPreviewDetailDto dto = memberReviewPreviewDetails.get(0); assertThat(dto.getId()).isNotNull(); assertThat(dto.getPostId()).isEqualTo(experience2.getId()); - assertThat(dto.getCategory()).isEqualTo(Category.EXPERIENCE); + assertThat(dto.getCategory()).isEqualTo(ExperienceType.ACTIVITY.name()); assertThat(dto.getPlaceName()).isEqualTo("experience title"); } @@ -333,7 +335,7 @@ void findReviewPreviewByMember3() { MemberReviewPreviewDetailDto dto = memberReviewPreviewDetails.get(0); assertThat(dto.getId()).isNotNull(); assertThat(dto.getPostId()).isEqualTo(experience2.getId()); - assertThat(dto.getCategory()).isEqualTo(Category.EXPERIENCE); + assertThat(dto.getCategory()).isEqualTo(ExperienceType.ACTIVITY.name()); assertThat(dto.getPlaceName()).isEqualTo("experience title"); } @@ -360,12 +362,4 @@ void findTotalCountByMember() { // then assertThat(totalCountByMember).isEqualTo(3); } - - @Test - void findExperienceMyReviewDetail() { - } - - @Test - void findRestaurantMyReviewDetail() { - } } \ No newline at end of file diff --git a/src/test/java/com/jeju/nanaland/domain/review/service/ReviewServiceTest.java b/src/test/java/com/jeju/nanaland/domain/review/service/ReviewServiceTest.java index 4f872e6d..4deb37a5 100644 --- a/src/test/java/com/jeju/nanaland/domain/review/service/ReviewServiceTest.java +++ b/src/test/java/com/jeju/nanaland/domain/review/service/ReviewServiceTest.java @@ -12,6 +12,7 @@ import com.jeju.nanaland.domain.common.data.Language; import com.jeju.nanaland.domain.common.dto.ImageFileDto; import com.jeju.nanaland.domain.common.entity.ImageFile; +import com.jeju.nanaland.domain.experience.entity.enums.ExperienceType; import com.jeju.nanaland.domain.member.dto.MemberResponse.MemberInfoDto; import com.jeju.nanaland.domain.member.entity.Member; import com.jeju.nanaland.domain.member.entity.enums.Provider; @@ -151,7 +152,7 @@ private Page createMemberReviewDetailList() { MemberReviewDetailDto.builder() .id((long) i) .postId(1L) - .category(Category.EXPERIENCE) + .category(ExperienceType.ACTIVITY.name()) .placeName("title") .createdAt(LocalDate.now()) .heartCount(5) @@ -168,7 +169,7 @@ private List createMemberReviewPreviewDetailList() MemberReviewPreviewDetailDto.builder() .id((long) i) .postId(1L) - .category(Category.EXPERIENCE) + .category(ExperienceType.ACTIVITY.name()) .placeName("title") .createdAt(LocalDate.now()) .heartCount(5)