From 2393c59bf72dc74e04e05916ea3a56bc5d5ab3cc Mon Sep 17 00:00:00 2001 From: JSoi Date: Tue, 12 Jul 2022 00:17:00 +0900 Subject: [PATCH] =?UTF-8?q?#23=20[Add]=20=EC=9C=84=EB=8F=84=20=EA=B2=BD?= =?UTF-8?q?=EB=8F=84=20=EB=B2=94=EC=9C=84=EB=A5=BC=20=ED=86=B5=ED=95=B4=20?= =?UTF-8?q?=EA=B7=BC=EC=B2=98=20=EA=B0=80=EA=B2=8C=20=EB=A6=AC=ED=84=B4=20?= =?UTF-8?q?=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.gradle | 4 ++++ .../store/controller/StoreController.java | 19 +++++++++++++++++++ 2 files changed, 23 insertions(+) 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()); + } }