Skip to content

Commit

Permalink
#23 [Add] 위도 경도 범위를 통해 근처 가게 리턴 구현
Browse files Browse the repository at this point in the history
  • Loading branch information
JSoi committed Jul 11, 2022
1 parent b2c8e54 commit 2393c59
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
4 changes: 4 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -85,4 +85,8 @@ configurations {
extendsFrom annotationProcessor
}
querydsl.extendsFrom compileClasspath
}
/*** comileQuerydsl.doFirst 추가*/
compileQuerydsl.doFirst {
if (file(querydslDir).exists()) delete(file(querydslDir))
}
Original file line number Diff line number Diff line change
@@ -1,24 +1,43 @@
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
@RequestMapping("/store")
public class StoreController {

private final StoreService storeService;
private final StoreQueryRepository storeQueryRepository;

@GetMapping
public List<StoreResponseDto> getStoreList() {
List<StoreResponseDto> storeList = storeService.getStoreList();
return storeList;
}

@GetMapping("/near")
public List<StoreResponseDto> 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<Store> betweenLngLat = storeQueryRepository.findBetweenLngLat(latStart, latEnd, lngStart, lngEnd, pageable);
return betweenLngLat.stream().map(storeService::storeToResDto).collect(Collectors.toList());
}
}

0 comments on commit 2393c59

Please sign in to comment.