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: 동행글 추천 조회 시 엔티티 직접 참조하도록 수정 #121

Merged
merged 1 commit into from
Dec 16, 2024
Merged
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 @@ -131,10 +131,11 @@ public List<CompanyPostResponseDTO> getRecentCompanyPosts() {
public List<CompanyPostResponseDTO> getNearbyCompanyPostsByLikeTravelArea(Long companyPostId, User user) {

// 여러 개의 travel area 중에서 첫 번째만 선택
CompanyPostResponseDTO post = getCompanyPostById(companyPostId).get(0);
CompanyPost companyPost = companyPostRepository.findById(companyPostId)
.orElseThrow(() -> new BadRequestException(ResponseCode.ROW_DOES_NOT_EXIST, "게시글을 찾을 수 없습니다. ID: " + companyPostId));

// 국가만 일치해도 조회되도록 국가 부분만 추출
String firstCountry = post.getTravelArea().get(0).split(" ")[0];
String firstCountry = companyPost.getTravelArea().get(0).split(" ")[0];

// 국가와 일치하는 다른 게시글을 조회, 현재 사용자가 작성한 게시글은 제외
List<CompanyPost> nearbyPosts = companyPostRepository.findTop5NearbyCompanyPosts(firstCountry, companyPostId, user, PageRequest.of(0, 5));
Expand Down