-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
[FEAT/#57] 위치 기반 장소 추천 알고리즘 구현
- Loading branch information
Showing
21 changed files
with
586 additions
and
111 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
src/main/java/com/acon/server/member/infra/repository/GuidedSpotCustomRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package com.acon.server.member.infra.repository; | ||
|
||
import com.acon.server.spot.api.response.SearchSuggestionResponse; | ||
import jakarta.persistence.EntityManager; | ||
import jakarta.persistence.PersistenceContext; | ||
import jakarta.persistence.Query; | ||
import java.util.List; | ||
import org.springframework.stereotype.Repository; | ||
|
||
@Repository | ||
public class GuidedSpotCustomRepository { | ||
|
||
@PersistenceContext | ||
private EntityManager em; | ||
|
||
public List<SearchSuggestionResponse> findRecentGuidedSpotSuggestions( | ||
Long memberId, | ||
double lat, | ||
double lon, | ||
double range, | ||
int limit | ||
) { | ||
String sql = """ | ||
SELECT s.id AS spot_id, | ||
s.name AS spot_name | ||
FROM guided_spot gs | ||
JOIN spot s ON s.id = gs.spot_id | ||
WHERE gs.member_id = :memberId | ||
AND ST_DWithin( | ||
s.geom::geography, | ||
ST_SetSRID(ST_MakePoint(:lon, :lat), 4326)::geography, | ||
:range | ||
) | ||
ORDER BY gs.updated_at DESC | ||
LIMIT :limit | ||
"""; | ||
|
||
Query nativeQuery = em.createNativeQuery(sql, "SearchSuggestionResponseMapping"); | ||
nativeQuery.setParameter("memberId", memberId); | ||
nativeQuery.setParameter("lat", lat); | ||
nativeQuery.setParameter("lon", lon); | ||
nativeQuery.setParameter("range", range); | ||
nativeQuery.setParameter("limit", limit); | ||
|
||
@SuppressWarnings("unchecked") | ||
List<SearchSuggestionResponse> result = nativeQuery.getResultList(); | ||
|
||
return result; | ||
} | ||
} |
2 changes: 2 additions & 0 deletions
2
src/main/java/com/acon/server/member/infra/repository/PreferenceRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,10 @@ | ||
package com.acon.server.member.infra.repository; | ||
|
||
import com.acon.server.member.infra.entity.PreferenceEntity; | ||
import java.util.Optional; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
public interface PreferenceRepository extends JpaRepository<PreferenceEntity, Long> { | ||
|
||
Optional<PreferenceEntity> findByMemberId(Long memberId); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 4 additions & 1 deletion
5
src/main/java/com/acon/server/spot/api/response/SpotListResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.