Skip to content

Commit

Permalink
feat(store): 서비스 불가지역에서 재검색시, 에러처리 #31
Browse files Browse the repository at this point in the history
  • Loading branch information
govl6113 committed Jun 22, 2023
1 parent de1c59c commit 218c32b
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -15,4 +16,9 @@ protected ResponseEntity<String> notFoundStoreException(NotFoundStoreException e
return ResponseEntity.status(HttpStatus.NOT_FOUND).body(exception.getMessage());
}

@ExceptionHandler(value = NotAllowedLocationException.class)
protected ResponseEntity<String> notAllowedLocationException(NotAllowedLocationException exception) {
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(exception.getMessage());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -45,6 +46,7 @@ public List<DistrictCountResponse> getCount() {
*/
@Override
public List<StoreResponse> getList(List<District> district, int page) {
// southwestLatitude, southwestLongitude, northeastLatitude, northeastLongitude는 null
return loadStorePort.getList(district, PageRequest.of(page - 1, 100), null, null, null, null);
}

Expand All @@ -63,6 +65,15 @@ public List<StoreResponse> 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,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package prography.cakeke.server.store.exceptions;

public class NotAllowedLocationException extends RuntimeException {
public NotAllowedLocationException() {
super("서비스 불가한 지역입니다.");
}
}

0 comments on commit 218c32b

Please sign in to comment.