From 4a961ba66e067912607d1f132787c07f983c5775 Mon Sep 17 00:00:00 2001 From: m020202 Date: Thu, 22 Aug 2024 17:27:06 +0900 Subject: [PATCH 1/3] =?UTF-8?q?fix:=20cors=20=EC=84=A4=EC=A0=95=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/example/locavel/config/WebConfig.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/example/locavel/config/WebConfig.java b/src/main/java/com/example/locavel/config/WebConfig.java index 2a7a260..8db7d19 100644 --- a/src/main/java/com/example/locavel/config/WebConfig.java +++ b/src/main/java/com/example/locavel/config/WebConfig.java @@ -11,13 +11,14 @@ public class WebConfig implements WebMvcConfigurer { @Override public void addCorsMappings(CorsRegistry registry) { registry.addMapping("/**") - .allowedOrigins("*") + .allowedOrigins("https://api.locavel.site","http://localhost:8080","http://43.203.42.179:8080") .allowedMethods( HttpMethod.GET.name(), HttpMethod.HEAD.name(), HttpMethod.POST.name(), HttpMethod.PUT.name(), HttpMethod.PATCH.name(), - HttpMethod.DELETE.name()); + HttpMethod.DELETE.name()) + .allowCredentials(true); } } From 87cc618e966fbbb171396f80644609cba50610e8 Mon Sep 17 00:00:00 2001 From: sangeun Date: Thu, 22 Aug 2024 18:18:56 +0900 Subject: [PATCH 2/3] =?UTF-8?q?fix=20:=20=EB=82=B4=20=EC=A7=80=EC=97=AD=20?= =?UTF-8?q?=EC=84=A4=EC=A0=95=20=ED=95=84=EC=88=98=20=EC=97=90=EB=9F=AC=20?= =?UTF-8?q?=EB=A9=94=EC=8B=9C=EC=A7=80=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../apiPayload/code/status/ErrorStatus.java | 1 + .../example/locavel/domain/enums/Traveler.java | 17 ++++++++++++----- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/example/locavel/apiPayload/code/status/ErrorStatus.java b/src/main/java/com/example/locavel/apiPayload/code/status/ErrorStatus.java index ac8796a..d09e7ae 100644 --- a/src/main/java/com/example/locavel/apiPayload/code/status/ErrorStatus.java +++ b/src/main/java/com/example/locavel/apiPayload/code/status/ErrorStatus.java @@ -41,6 +41,7 @@ public enum ErrorStatus implements BaseErrorCode { //유저 USER_NOT_FOUND(HttpStatus.NOT_FOUND, "USER4001","해당 유저가 존재하지 않습니다."), USER_SAME(HttpStatus.BAD_REQUEST,"USER4002","본인입니다."), + USER_REGION_NOT_FOUND(HttpStatus.NOT_FOUND, "USER4003", "내 지역 설정은 필수 입니다. 설정 후 다시 시도해주세요."), //팔로우 FOLLOWING_NOT_FOUND(HttpStatus.NOT_FOUND, "FOLLOW4001","팔로우 중이 아닙니다."), diff --git a/src/main/java/com/example/locavel/domain/enums/Traveler.java b/src/main/java/com/example/locavel/domain/enums/Traveler.java index 19e3dd2..f818267 100644 --- a/src/main/java/com/example/locavel/domain/enums/Traveler.java +++ b/src/main/java/com/example/locavel/domain/enums/Traveler.java @@ -1,5 +1,7 @@ package com.example.locavel.domain.enums; +import com.example.locavel.apiPayload.code.status.ErrorStatus; +import com.example.locavel.apiPayload.exception.handler.UserHandler; import com.example.locavel.domain.Places; import com.example.locavel.domain.User; import com.fasterxml.jackson.annotation.JsonCreator; @@ -15,12 +17,17 @@ public enum Traveler { // 유저의 현지인/여행객 판단 public static Traveler of(Places place, User user) { - Long userRegion = user.getMy_area().getId(); - Long placeRegion = place.getRegion().getId(); - if (userRegion == placeRegion || userRegion.equals(placeRegion)) { - return NO; // 현지인 + if(user.getMy_area() == null) { + throw new UserHandler(ErrorStatus.USER_REGION_NOT_FOUND); + } + else { + Long userRegion = user.getMy_area().getId(); + Long placeRegion = place.getRegion().getId(); + if (userRegion == placeRegion || userRegion.equals(placeRegion)) { + return NO; // 현지인 + } + else return YES; //여행객 } - else return YES; //여행객 } @JsonValue public String getViewName() { From 8d8251c43b2ba6940cb09af0bc45925a1260c447 Mon Sep 17 00:00:00 2001 From: qzzloz Date: Thu, 22 Aug 2024 19:04:10 +0900 Subject: [PATCH 3/3] =?UTF-8?q?sql=20=EC=BF=BC=EB=A6=AC=20Places=20?= =?UTF-8?q?=ED=85=8C=EC=9D=B4=EB=B8=94=EB=AA=85=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/example/locavel/repository/PlaceRepository.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/example/locavel/repository/PlaceRepository.java b/src/main/java/com/example/locavel/repository/PlaceRepository.java index 83cd0f3..fcc9c19 100644 --- a/src/main/java/com/example/locavel/repository/PlaceRepository.java +++ b/src/main/java/com/example/locavel/repository/PlaceRepository.java @@ -29,7 +29,7 @@ List findPlacesInRange( "(6371 * acos(cos(radians(:latitude)) * cos(radians(latitude)) * " + "cos(radians(longitude) - radians(:longitude)) + sin(radians(:latitude)) * " + "sin(radians(latitude)))) AS distance " + - "FROM Places " + + "FROM places " + "HAVING distance < :radius " + "ORDER BY distance", nativeQuery = true) List findNearbyPlaces(@Param("latitude")double latitude,