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

[BLOOM-089] 위치등록시 위치명 중복 예외 추가 #90

Merged
merged 3 commits into from
Aug 29, 2024

Conversation

Dompoo
Copy link
Collaborator

@Dompoo Dompoo commented Aug 28, 2024

How

  • ErrorType을 정의하고, LocationService에서 조건을 체크한 후 예외를 터트리도록 했습니다.

Result

  • 이제 중복된 Location명에 대해 체크할 수 있게 되었습니다.

@Dompoo Dompoo added the 🔨 fix Request a fix for an existing feature label Aug 28, 2024
@Dompoo Dompoo self-assigned this Aug 28, 2024
@Dompoo Dompoo requested a review from stophwan as a code owner August 28, 2024 14:16
@Dompoo Dompoo linked an issue Aug 28, 2024 that may be closed by this pull request
Comment on lines 27 to 34
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)
Copy link
Member

Choose a reason for hiding this comment

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

'위치 등록 한도가 넘었을때' '이미 등록된 위치에 등록하려했을때' 두 가지 예외사항이 있는데 둘 다 별도의 private 메서드로 하면 가독성이 높아지지 않을까 생각합니다.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

좋은 지점인 것 같아요! 리팩터링 했습니다~ refactor: LocationService 검증 코드를 별도의 private 메서드로 추출

Copy link
Member

@stophwan stophwan left a comment

Choose a reason for hiding this comment

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

굿입니다~~~!!

@Dompoo Dompoo merged commit 6d0453d into main Aug 29, 2024
1 check passed
@Dompoo Dompoo deleted the fix/location-add branch September 18, 2024 05:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🔨 fix Request a fix for an existing feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[fix] 위치 장소명 중복 예외 추가
2 participants