1414
1515public interface MountainRepository extends JpaRepository <Mountain , Long > {
1616
17- @ Query ("SELECT m FROM Mountain m WHERE m.name LIKE CONCAT('%', :keyword, '%') OR m.address LIKE CONCAT('%', :keyword, '%')" )
17+ @ Query ("SELECT m FROM Mountain m WHERE m.isPublic = true AND (m. name LIKE CONCAT('%', :keyword, '%') OR m.address LIKE CONCAT('%', :keyword, '%') )" )
1818 Page <Mountain > searchByKeyword (@ Param ("keyword" ) String keyword , Pageable pageable );
1919
20+ Page <Mountain > findByIsPublicTrue (Pageable pageable );
21+
2022 /**
2123 * 주어진 좌표(lat, lng)에서 가장 가까운 산 1개를 PostGIS 거리 연산자로 조회한다.
2224 * `<->` : PostGIS 거리 연산자, GIST 인덱스(idx_mountains_location)로 가속됨.
@@ -27,6 +29,7 @@ public interface MountainRepository extends JpaRepository<Mountain, Long> {
2729 value = """
2830 SELECT * FROM mountains
2931 WHERE location IS NOT NULL
32+ AND is_public = true
3033 ORDER BY location <-> ST_SetSRID(ST_MakePoint(:lng, :lat), 4326)::geography
3134 LIMIT 1
3235 """ ,
@@ -53,13 +56,15 @@ public interface MountainRepository extends JpaRepository<Mountain, Long> {
5356 WHERE difficulty IN (:difficulties)
5457 AND latitude IS NOT NULL
5558 AND longitude IS NOT NULL
59+ AND is_public = true
5660 ORDER BY (POWER(latitude - :lat, 2) + POWER((longitude - :lng) * COS(RADIANS(:lat)), 2)) ASC, id ASC
5761 """ ,
5862 countQuery = """
5963 SELECT COUNT(*) FROM mountains
6064 WHERE difficulty IN (:difficulties)
6165 AND latitude IS NOT NULL
6266 AND longitude IS NOT NULL
67+ AND is_public = true
6368 """ ,
6469 nativeQuery = true
6570 )
@@ -84,6 +89,7 @@ Page<Mountain> findRecommendationsByDifficulties(
8489 LEFT JOIN hiking_members hm ON hm.hiking_record_id = hr.id AND hm.user_id = :userId
8590 WHERE m.latitude BETWEEN :swLat AND :neLat
8691 AND m.longitude BETWEEN :swLng AND :neLng
92+ AND m.is_public = true
8793 GROUP BY m.id
8894 ORDER BY m.id
8995 """ ,
0 commit comments