Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/#543 experience #544

Merged
merged 2 commits into from
Jan 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,15 @@ public PostPreviewDto(Long id, String title, String originUrl, String thumbnailU
this.firstImage = new ImageFileDto(originUrl, thumbnailUrl);
}

@QueryProjection
public PostPreviewDto(Long id, String title, String category, String originUrl,
String thumbnailUrl) {
this.id = id;
this.title = title;
this.category = category;
this.firstImage = new ImageFileDto(originUrl, thumbnailUrl);
}

public PostPreviewDto(PostPreviewDto postPreviewDto) {
this.id = postPreviewDto.getId();
this.title = postPreviewDto.getTitle();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.jeju.nanaland.domain.common.data.Language;
import com.jeju.nanaland.domain.common.dto.CompositeDto;
import com.jeju.nanaland.domain.experience.entity.enums.ExperienceType;
import com.querydsl.core.annotations.QueryProjection;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
Expand All @@ -22,17 +23,20 @@ public class ExperienceCompositeDto extends CompositeDto {
private String details;
private String amenity;
private String fee;
private ExperienceType experienceType;

@QueryProjection
public ExperienceCompositeDto(Long id, String originUrl, String thumbnailUrl, String contact,
String homepage, Language language, String title, String content, String address,
String addressTag, String intro, String details, String time, String amenity, String fee) {
String addressTag, String intro, String details, String time, String amenity, String fee,
ExperienceType experienceType) {
super(id, originUrl, thumbnailUrl, contact, language, title, content, address, addressTag,
time);
this.intro = intro;
this.details = details;
this.amenity = amenity;
this.fee = fee;
this.homepage = homepage;
this.experienceType = experienceType;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ public ExperienceCompositeDto findCompositeDtoById(Long id, Language language) {
experienceTrans.details,
experienceTrans.time,
experienceTrans.amenity,
experienceTrans.fee
experienceTrans.fee,
experience.experienceType
))
.from(experience)
.leftJoin(experience.firstImageFile, imageFile)
Expand Down Expand Up @@ -101,7 +102,8 @@ public ExperienceCompositeDto findCompositeDtoByIdWithPessimisticLock(Long id,
experienceTrans.details,
experienceTrans.time,
experienceTrans.amenity,
experienceTrans.fee
experienceTrans.fee,
experience.experienceType
))
.from(experience)
.leftJoin(experience.firstImageFile, imageFile)
Expand Down Expand Up @@ -357,6 +359,7 @@ public PostPreviewDto findPostPreviewDto(Long postId, Language language) {
.select(new QPostPreviewDto(
experience.id,
experienceTrans.title,
experience.experienceType.stringValue(),
imageFile.originUrl,
imageFile.thumbnailUrl
))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import com.jeju.nanaland.domain.common.data.AddressTag;
import com.jeju.nanaland.domain.common.data.Category;
import com.jeju.nanaland.domain.common.data.Language;
import com.jeju.nanaland.domain.common.data.PostCategory;
import com.jeju.nanaland.domain.common.dto.ImageFileDto;
import com.jeju.nanaland.domain.common.dto.PostPreviewDto;
import com.jeju.nanaland.domain.common.entity.Post;
Expand Down Expand Up @@ -79,7 +78,6 @@ public PostPreviewDto getPostPreviewDto(Long postId, Category category, Language
Optional.ofNullable(postPreviewDto)
.orElseThrow(() -> new NotFoundException("해당 게시물을 찾을 수 없습니다."));

postPreviewDto.setCategory(PostCategory.EXPERIENCE.toString());
return postPreviewDto;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,8 @@ public BaseResponse<List<PopularPostPreviewDto>> getPopularPosts(
}

@Operation(
summary = "랜덤 추천 게시물 2개 반환",
description = "홈에서 보여질 랜덤 추천 게시물 2개 반환")
summary = "랜덤 추천 게시물 3개 반환",
description = "홈에서 보여질 랜덤 추천 게시물 3개 반환")
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "성공"),
@ApiResponse(responseCode = "400", description = "결과 타입에 없는 값으로 요청", content = @Content),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.jeju.nanaland.domain.member.dto;

import com.jeju.nanaland.domain.common.data.Category;
import com.jeju.nanaland.domain.common.data.Language;
import com.jeju.nanaland.domain.common.dto.ImageFileDto;
import com.jeju.nanaland.domain.member.entity.Member;
Expand Down Expand Up @@ -41,7 +40,7 @@ public static class RecommendPostDto {
description = "게시물 카테고리",
example = "NATURE",
allowableValues = {
"NATURE", "EXPERIENCE", "FESTIVAL", "MARKET", "RESTAURANT"
"NATURE", "ACTIVITY", "CULTURE_AND_ARTS", "FESTIVAL", "MARKET", "RESTAURANT"
})
private String category;

Expand All @@ -58,10 +57,10 @@ public static class RecommendPostDto {
private boolean isFavorite;

@QueryProjection
public RecommendPostDto(Long id, Category categoryContent, String originUrl,
public RecommendPostDto(Long id, String category, String originUrl,
String thumbnailUrl, String title, String introduction) {
this.id = id;
this.category = categoryContent.name();
this.category = category;
this.firstImage = new ImageFileDto(originUrl, thumbnailUrl);
this.title = title;
this.introduction = introduction;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
import com.jeju.nanaland.domain.member.dto.MemberResponse;
import com.jeju.nanaland.domain.member.dto.QMemberResponse_RecommendPostDto;
import com.jeju.nanaland.domain.member.entity.enums.TravelType;
import com.querydsl.core.types.dsl.CaseBuilder;
import com.querydsl.core.types.dsl.Expressions;
import com.querydsl.jpa.impl.JPAQueryFactory;
import java.util.List;
import lombok.RequiredArgsConstructor;
Expand All @@ -35,7 +37,7 @@ public MemberResponse.RecommendPostDto findNatureRecommendPostDto(Long postId, L
return queryFactory
.select(new QMemberResponse_RecommendPostDto(
recommend.post.id,
recommend.category,
recommend.category.stringValue(),
imageFile.originUrl,
imageFile.thumbnailUrl,
recommendTrans.title.coalesce(natureTrans.title),
Expand Down Expand Up @@ -65,7 +67,11 @@ public MemberResponse.RecommendPostDto findExperienceRecommendPostDto(Long postI
return queryFactory
.select(new QMemberResponse_RecommendPostDto(
recommend.post.id,
recommend.category,
Expressions.asString("")
.append(new CaseBuilder()
.when(experience.experienceType.stringValue().eq("ACTIVITY"))
.then("ACTIVITY")
.otherwise("CULTURE_AND_ARTS")),
imageFile.originUrl,
imageFile.thumbnailUrl,
recommendTrans.title.coalesce(experienceTrans.title),
Expand Down Expand Up @@ -94,7 +100,7 @@ public MemberResponse.RecommendPostDto findMarketRecommendPostDto(Long postId, L
return queryFactory
.select(new QMemberResponse_RecommendPostDto(
recommend.post.id,
recommend.category,
recommend.category.stringValue(),
imageFile.originUrl,
imageFile.thumbnailUrl,
recommendTrans.title.coalesce(marketTrans.title),
Expand Down Expand Up @@ -124,7 +130,7 @@ public MemberResponse.RecommendPostDto findFestivalRecommendPostDto(Long postId,
return queryFactory
.select(new QMemberResponse_RecommendPostDto(
recommend.post.id,
recommend.category,
recommend.category.stringValue(),
imageFile.originUrl,
imageFile.thumbnailUrl,
recommendTrans.title.coalesce(festivalTrans.title),
Expand Down Expand Up @@ -152,7 +158,7 @@ public MemberResponse.RecommendPostDto findNanaRecommendPostDto(Long postId, Lan
return queryFactory
.select(new QMemberResponse_RecommendPostDto(
recommend.post.id,
recommend.category,
recommend.category.stringValue(),
imageFile.originUrl,
imageFile.thumbnailUrl,
recommendTrans.title.coalesce(nanaTitle.heading),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ private MemberResponse.RecommendPostDto getExperiencePostDto(Member member, Long
language);
MemberResponse.RecommendPostDto recommendPostDto = MemberResponse.RecommendPostDto.builder()
.id(compositeDto.getId())
.category(Category.EXPERIENCE.name())
.category(compositeDto.getExperienceType().name())
.title(compositeDto.getTitle())
.firstImage(compositeDto.getFirstImage())
.build();
Expand Down
Loading