diff --git a/build.gradle b/build.gradle index 5588e0a..dbdb451 100644 --- a/build.gradle +++ b/build.gradle @@ -85,4 +85,8 @@ configurations { extendsFrom annotationProcessor } querydsl.extendsFrom compileClasspath +} +/*** comileQuerydsl.doFirst 추가*/ +compileQuerydsl.doFirst { + if (file(querydslDir).exists()) delete(file(querydslDir)) } \ No newline at end of file diff --git a/src/main/java/com/mpnp/baechelin/store/controller/StoreController.java b/src/main/java/com/mpnp/baechelin/store/controller/StoreController.java index 43e6e2d..9b5d3c3 100644 --- a/src/main/java/com/mpnp/baechelin/store/controller/StoreController.java +++ b/src/main/java/com/mpnp/baechelin/store/controller/StoreController.java @@ -1,13 +1,19 @@ package com.mpnp.baechelin.store.controller; +import com.mpnp.baechelin.store.domain.Store; import com.mpnp.baechelin.store.dto.StoreResponseDto; import com.mpnp.baechelin.store.service.StoreService; import lombok.RequiredArgsConstructor; +import org.springframework.data.domain.Pageable; +import org.springframework.data.web.PageableDefault; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; +import java.math.BigDecimal; import java.util.List; +import java.util.stream.Collectors; @RestController @RequiredArgsConstructor @@ -15,10 +21,23 @@ public class StoreController { private final StoreService storeService; + private final StoreQueryRepository storeQueryRepository; @GetMapping public List getStoreList() { List storeList = storeService.getStoreList(); return storeList; } + + @GetMapping("/near") + public List giveStoreInRange(@RequestParam BigDecimal latStart, + @RequestParam BigDecimal latEnd, + @RequestParam BigDecimal lngStart, + @RequestParam BigDecimal lngEnd, + // sort 기준 정하기 + //@PageableDefault(sort = {""}, direction = Sort.Direction.DESC) Pageable pageable){ + @PageableDefault Pageable pageable) { + List betweenLngLat = storeQueryRepository.findBetweenLngLat(latStart, latEnd, lngStart, lngEnd, pageable); + return betweenLngLat.stream().map(storeService::storeToResDto).collect(Collectors.toList()); + } }