From f454a4081116b61bd38bab6e8005c99eae9fe18a Mon Sep 17 00:00:00 2001 From: chaechaen Date: Mon, 16 Dec 2024 15:40:33 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=EB=8F=99=ED=96=89=EA=B8=80=20=EC=B6=94?= =?UTF-8?q?=EC=B2=9C=20=EC=A1=B0=ED=9A=8C=20=EC=8B=9C=20=EC=97=94=ED=8B=B0?= =?UTF-8?q?=ED=8B=B0=20=EC=A7=81=EC=A0=91=20=EC=B0=B8=EC=A1=B0=ED=95=98?= =?UTF-8?q?=EB=8F=84=EB=A1=9D=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/companyPost/application/CompanyPostService.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/on/server/domain/companyPost/application/CompanyPostService.java b/src/main/java/com/on/server/domain/companyPost/application/CompanyPostService.java index c24c30b..2cad6a3 100644 --- a/src/main/java/com/on/server/domain/companyPost/application/CompanyPostService.java +++ b/src/main/java/com/on/server/domain/companyPost/application/CompanyPostService.java @@ -131,10 +131,11 @@ public List getRecentCompanyPosts() { public List 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 nearbyPosts = companyPostRepository.findTop5NearbyCompanyPosts(firstCountry, companyPostId, user, PageRequest.of(0, 5));