-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
23 additions
and
0 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
19 changes: 19 additions & 0 deletions
19
src/main/java/com/mpnp/baechelin/store/controller/StoreController.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,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()); | ||
} | ||
} |