diff --git a/src/main/java/prography/cakeke/server/store/adapter/in/web/StoreExceptionController.java b/src/main/java/prography/cakeke/server/store/adapter/in/web/StoreExceptionController.java index 493966d..bb630cc 100644 --- a/src/main/java/prography/cakeke/server/store/adapter/in/web/StoreExceptionController.java +++ b/src/main/java/prography/cakeke/server/store/adapter/in/web/StoreExceptionController.java @@ -5,6 +5,7 @@ import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.bind.annotation.RestControllerAdvice; +import prography.cakeke.server.store.exceptions.NotAllowedLocationException; import prography.cakeke.server.store.exceptions.NotFoundStoreException; @RestControllerAdvice @@ -15,4 +16,9 @@ protected ResponseEntity notFoundStoreException(NotFoundStoreException e return ResponseEntity.status(HttpStatus.NOT_FOUND).body(exception.getMessage()); } + @ExceptionHandler(value = NotAllowedLocationException.class) + protected ResponseEntity notAllowedLocationException(NotAllowedLocationException exception) { + return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(exception.getMessage()); + } + } \ No newline at end of file diff --git a/src/main/java/prography/cakeke/server/store/application/service/StoreService.java b/src/main/java/prography/cakeke/server/store/application/service/StoreService.java index f242292..1190b7f 100644 --- a/src/main/java/prography/cakeke/server/store/application/service/StoreService.java +++ b/src/main/java/prography/cakeke/server/store/application/service/StoreService.java @@ -18,6 +18,7 @@ import prography.cakeke.server.store.application.port.out.LoadStorePort; import prography.cakeke.server.store.domain.District; import prography.cakeke.server.store.domain.Store; +import prography.cakeke.server.store.exceptions.NotAllowedLocationException; import prography.cakeke.server.store.exceptions.NotFoundStoreException; @Service @@ -45,6 +46,7 @@ public List getCount() { */ @Override public List getList(List district, int page) { + // southwestLatitude, southwestLongitude, northeastLatitude, northeastLongitude는 null return loadStorePort.getList(district, PageRequest.of(page - 1, 100), null, null, null, null); } @@ -63,6 +65,15 @@ public List reload( Double southwestLatitude, Double southwestLongitude, Double northeastLatitude, Double northeastLongitude ) { + // 서울시 외곽의 서비스 불가 지역 체크 + if (northeastLatitude < 37.4289 || southwestLatitude > 37.7010) { + throw new NotAllowedLocationException(); + } + if (northeastLongitude < 126.7649 || southwestLongitude > 127.1839) { + throw new NotAllowedLocationException(); + } + + // district는 null return loadStorePort.getList( null, PageRequest.of(page - 1, 100), southwestLatitude, southwestLongitude, diff --git a/src/main/java/prography/cakeke/server/store/exceptions/NotAllowedLocationException.java b/src/main/java/prography/cakeke/server/store/exceptions/NotAllowedLocationException.java new file mode 100644 index 0000000..b76519d --- /dev/null +++ b/src/main/java/prography/cakeke/server/store/exceptions/NotAllowedLocationException.java @@ -0,0 +1,7 @@ +package prography.cakeke.server.store.exceptions; + +public class NotAllowedLocationException extends RuntimeException { + public NotAllowedLocationException() { + super("서비스 불가한 지역입니다."); + } +}