From 5e4d200ce98b34b6bba0c7174f53b9d213ff9dc4 Mon Sep 17 00:00:00 2001 From: dong_yxxn Date: Thu, 14 Nov 2024 16:58:48 +0900 Subject: [PATCH 1/2] =?UTF-8?q?[refactor]:=20findPlacesByDistance=EC=97=90?= =?UTF-8?q?=EC=84=9C=20pagenation=20=EC=A0=95=EC=83=81=ED=99=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - pagenation이 정상적으로 작동하도록 countQuery 생성후 적용하였습니다. --- .../place/persistence/PlaceCustomRepositoryImpl.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/team7/inplace/place/persistence/PlaceCustomRepositoryImpl.java b/src/main/java/team7/inplace/place/persistence/PlaceCustomRepositoryImpl.java index 6d6688aa..0497888f 100644 --- a/src/main/java/team7/inplace/place/persistence/PlaceCustomRepositoryImpl.java +++ b/src/main/java/team7/inplace/place/persistence/PlaceCustomRepositoryImpl.java @@ -9,7 +9,6 @@ import java.util.stream.Collectors; import lombok.AllArgsConstructor; import org.springframework.data.domain.Page; -import org.springframework.data.domain.PageImpl; import org.springframework.data.domain.Pageable; import org.springframework.data.support.PageableExecutionUtils; import org.springframework.stereotype.Repository; @@ -40,7 +39,10 @@ public Page findPlacesByDistance(String longitude, String latitude, Pagea .limit(pageable.getPageSize()) .fetch(); - return new PageImpl<>(places, pageable, places.size()); + JPAQuery countQuery = jpaQueryFactory.select(place.id.count()) // 중복 제거 + .from(place); + + return PageableExecutionUtils.getPage(places, pageable, countQuery::fetchOne); } @Override From d21dfe046e199c663e753d048666b33595aee87f Mon Sep 17 00:00:00 2001 From: dong_yxxn Date: Thu, 14 Nov 2024 20:12:36 +0900 Subject: [PATCH 2/2] =?UTF-8?q?[fix]:=20schema.sql=EC=97=90=20,=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - conflict merge하며 ,빠진 부분을 추가했습니다. --- src/main/resources/sql/schema.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/sql/schema.sql b/src/main/resources/sql/schema.sql index f0b39453..c91e05f2 100644 --- a/src/main/resources/sql/schema.sql +++ b/src/main/resources/sql/schema.sql @@ -22,7 +22,7 @@ create table places latitude text not null, longitude text not null, menu_img_url text null, - category enum ('CAFE', 'JAPANESE', 'KOREAN', 'NONE', 'RESTAURANT', 'WESTERN') not null + category enum ('CAFE', 'JAPANESE', 'KOREAN', 'NONE', 'RESTAURANT', 'WESTERN') not null, FULLTEXT INDEX ft_name_ngram (name) WITH PARSER ngram, INDEX idx_long_lat (longitude(15), latitude(15))