Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BE] refactor: 놀이터 전체조회->범위조회로 변경 #780

Merged
merged 3 commits into from
Jan 4, 2025

Conversation

ehtjsv2
Copy link
Contributor

@ehtjsv2 ehtjsv2 commented Jan 3, 2025

이슈

개발 사항

  • 놀이터 전체조회를 위도경도 범위로 조회하도록 변경했습니다.
    • 위도 경도 기본 값으로 한국 극단지점위치로 했습니다. 이로 인해, 이전 안드로이드어플 버전은 자동으로 한국 전체범위조회로 조회됩니다
  • 내가 참여한 놀이터 조회API 구현
    • 범위조회로 바뀌었지만, 참여한 놀이터는 항상 지도에 있어야 하기 때문에, 내가 참여한 놀이터 조회API를 별도로 만들었습니다.

@ehtjsv2 ehtjsv2 added 🛠️ refactor 리팩터링 🖥 backend backend ✨ feat 기능 개발 labels Jan 3, 2025
@ehtjsv2 ehtjsv2 self-assigned this Jan 3, 2025
Copy link

github-actions bot commented Jan 3, 2025

Test Results

230 tests   230 ✅  31s ⏱️
 47 suites    0 💤
 47 files      0 ❌

Results for commit 3689969.

Copy link
Contributor

@takoyakimchi takoyakimchi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Comment on lines 73 to +80
@GetMapping("/locations")
public ApiResponse<List<FindPlaygroundLocationResponse>> findAllLocation(@Auth Long memberId) {
return ApiResponse.ofSuccess(playgroundQueryService.findLocations(memberId));
public ApiResponse<List<FindPlaygroundLocationResponse>> findAllLocations(
@Auth Long memberId,
@RequestParam(defaultValue = MIN_KOREA_LATITUDE) double startLatitude,
@RequestParam(defaultValue = MAX_KOREA_LATITUDE) double endLatitude,
@RequestParam(defaultValue = MIN_KOREA_LONGITUDE) double startLongitude,
@RequestParam(defaultValue = MAX_KOREA_LONGITUDE) double endLongitude
) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

명세가 바뀌었네요. 실 사용자 없어서 버전 관리 안한 것이 맞을까요?!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

defaultValue가 있어서 이전 버전에서 쓰면 전체 조회 되는거죠?!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ModelAttribute로 받으면 더 깔끔할 것 같기도~?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

같은 방법을 생각했었는데, 일단 보일러 플레이트제거를 위해 Record를 사용했다면, 아래와 같은 코드가 나옵니다.

public record FindPlaygroundLocationRequest(
        Double startLatitude,
        Double endLatitude,
        Double startLongitude,
        Double endLongitude
) {

    private static final double MIN_KOREA_LATITUDE = 33.0637;
    private static final double MAX_KOREA_LATITUDE = 43.0042;
    private static final double MIN_KOREA_LONGITUDE = 124.1104;
    private static final double MAX_KOREA_LONGITUDE = 131.4220;

    public FindPlaygroundLocationRequest {
        startLatitude = startLatitude == null ? MIN_KOREA_LATITUDE : startLatitude;
        endLatitude = endLatitude == null ? MAX_KOREA_LATITUDE : endLatitude;
        startLongitude = startLongitude == null ? MIN_KOREA_LONGITUDE : startLongitude;
        endLongitude = endLongitude == null ? MAX_KOREA_LONGITUDE : endLongitude;
    }
}

래퍼타입이 아닌 double을 하면 null로 입력을 못받기에 래퍼타입을 사용했고, 해당 로직으로 기본값을 설정해주게 됩니다.
불필요한 래퍼타입을 사용하기도하고, 해당 로직이 Dto에 들어가기에는 겉으로 들어나야하는 중요한 로직이 아닐까라는 생각으로 컨트롤러에 드러냈습니다

Comment on lines 73 to +80
@GetMapping("/locations")
public ApiResponse<List<FindPlaygroundLocationResponse>> findAllLocation(@Auth Long memberId) {
return ApiResponse.ofSuccess(playgroundQueryService.findLocations(memberId));
public ApiResponse<List<FindPlaygroundLocationResponse>> findAllLocations(
@Auth Long memberId,
@RequestParam(defaultValue = MIN_KOREA_LATITUDE) double startLatitude,
@RequestParam(defaultValue = MAX_KOREA_LATITUDE) double endLatitude,
@RequestParam(defaultValue = MIN_KOREA_LONGITUDE) double startLongitude,
@RequestParam(defaultValue = MAX_KOREA_LONGITUDE) double endLongitude
) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ModelAttribute로 받으면 더 깔끔할 것 같기도~?

Comment on lines 73 to +80
@GetMapping("/locations")
public ApiResponse<List<FindPlaygroundLocationResponse>> findAllLocation(@Auth Long memberId) {
return ApiResponse.ofSuccess(playgroundQueryService.findLocations(memberId));
public ApiResponse<List<FindPlaygroundLocationResponse>> findAllLocations(
@Auth Long memberId,
@RequestParam(defaultValue = MIN_KOREA_LATITUDE) double startLatitude,
@RequestParam(defaultValue = MAX_KOREA_LATITUDE) double endLatitude,
@RequestParam(defaultValue = MIN_KOREA_LONGITUDE) double startLongitude,
@RequestParam(defaultValue = MAX_KOREA_LONGITUDE) double endLongitude
) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ehtjsv2 ehtjsv2 merged commit bbd917c into develop Jan 4, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🖥 backend backend ✨ feat 기능 개발 🛠️ refactor 리팩터링
Projects
None yet
Development

Successfully merging this pull request may close these issues.

놀이터 전체조회 범위 조회로 변경
4 participants