Skip to content

Commit

Permalink
Merge pull request #61 from EFUB4-Jukebox/feat/home
Browse files Browse the repository at this point in the history
[Hotfix]
  • Loading branch information
seohyun-lee authored Jul 17, 2024
2 parents 1aa685c + c39fd70 commit f8ec0ff
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package sws.songpin.domain.member.controller;

import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.RestController;

@Tag(name = "Home", description = "Home 기능 관련 API입니다.")
@RestController
@RequiredArgsConstructor
public class HomeController {

}
11 changes: 11 additions & 0 deletions src/main/java/sws/songpin/domain/member/service/HomeService.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package sws.songpin.domain.member.service;

import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@Transactional
@RequiredArgsConstructor
public class HomeService {
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,20 @@
import sws.songpin.domain.place.entity.Place;

import java.time.LocalDate;
import java.util.List;
import java.util.Optional;

public interface PlaceRepository extends JpaRepository<Place, Long> {
Optional<Place> findByProviderAddressId(Long providerAddressId);

// 좌표 범위에 포함되는 장소들 불러오기
@Query(value = "SELECT p.* FROM Place p " +
@Query(value = "SELECT p.* FROM place p " +
"JOIN pin ON p.place_id = pin.place_id " +
"WHERE p.latitude BETWEEN :swLat AND :neLat " +
"AND p.longitude BETWEEN :swLng AND :neLng " +
"GROUP BY p.place_id " +
"HAVING COUNT(pin.pin_id) > 0 " +
"ORDER BY MAX(pin.listened_date) DESC, p.place_id DESC",
countQuery = "SELECT COUNT(DISTINCT p.place_id) FROM Place p " +
countQuery = "SELECT COUNT(DISTINCT p.place_id) FROM place p " +
"JOIN pin ON p.place_id = pin.place_id " +
"WHERE p.latitude BETWEEN :swLat AND :neLat " +
"AND p.longitude BETWEEN :swLng AND :neLng " +
Expand All @@ -38,15 +37,15 @@ Page<Place> findAllByLatitudeBetweenAndLongitudeBetween(
);

// 좌표 범위 & 기간 범위에 모두 포함되는 장소들 불러오기
@Query(value = "SELECT p.* FROM Place p " +
@Query(value = "SELECT p.* FROM place p " +
"JOIN pin ON p.place_id = pin.place_id " +
"WHERE p.latitude BETWEEN :swLat AND :neLat " +
"AND p.longitude BETWEEN :swLng AND :neLng " +
"AND pin.listened_date BETWEEN :startDate AND :endDate " +
"GROUP BY p.place_id " +
"HAVING COUNT(pin.pin_id) > 0 " +
"ORDER BY MAX(pin.listened_date) DESC, p.place_id DESC",
countQuery = "SELECT COUNT(DISTINCT p.place_id) FROM Place p " +
countQuery = "SELECT COUNT(DISTINCT p.place_id) FROM place p " +
"JOIN pin ON p.place_id = pin.place_id " +
"WHERE p.latitude BETWEEN :swLat AND :neLat " +
"AND p.longitude BETWEEN :swLng AND :neLng " +
Expand Down

0 comments on commit f8ec0ff

Please sign in to comment.