-
Notifications
You must be signed in to change notification settings - Fork 0
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
[BLOOM-089] 위치등록시 위치명 중복 예외 추가 #90
Conversation
Dompoo
commented
Aug 28, 2024
- ErrorType을 정의하고, LocationService에서 조건을 체크한 후 예외를 터트리도록 했습니다.
- 이제 중복된 Location명에 대해 체크할 수 있게 되었습니다.
val locations = locationRepository.findAllByUser(user) | ||
|
||
if (locations.size >= MAX_LOCATION_LIMIT) throw BadRequestException(ErrorType.LOCATION_COUNT_EXCEED) | ||
if (locations.any { location -> | ||
location.name == dto.name | ||
} | ||
) { | ||
throw BadRequestException(ErrorType.LOCATION_NAME_DUPLICATE) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'위치 등록 한도가 넘었을때' '이미 등록된 위치에 등록하려했을때' 두 가지 예외사항이 있는데 둘 다 별도의 private 메서드로 하면 가독성이 높아지지 않을까 생각합니다.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
좋은 지점인 것 같아요! 리팩터링 했습니다~ refactor: LocationService 검증 코드를 별도의 private 메서드로 추출
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
굿입니다~~~!!