-
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
[FIX/#82] 이미 인증된 동네가 존재할 때 동네 인증 재진행 시 예외 처리 추가 #83
Conversation
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 boolean existsVerifiedAreaByMemberId(Long memberId) { | ||
List<VerifiedAreaEntity> verifiedAreaEntityList = verifiedAreaRepository.findAllByMemberId(memberId); | ||
return !verifiedAreaEntityList.isEmpty(); | ||
} |
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.
P2:
이거 JPA 메서드로 할 수 있을 것 같기도 한데요 ?!
public interface VerifiedAreaRepository extends JpaRepository<VerifiedAreaEntity, Long> {
boolean existsByMemberId(Long memberId);
}
이런 느낌?
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.
그렇네용 수정했습니다~!
2cf0b7c
// 추후 여러 동네 인증이 가능하게 되면 제거 예정 | ||
if (existsVerifiedAreaByMemberId(memberEntity.getId())) { | ||
throw new BusinessException(ErrorType.ALREADY_VERIFIED_AREA_ERROR); | ||
} |
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.
Q2:
요거 추후 한 동네에 대한 재인증 로직이 추가되면 어떻게 수정할 예정이신가요 ?!
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.
아마 그런 로직이 추가될 때쯤 원래 기획대로 여러 동네 인증이 가능하지 않을까 싶어요!
일단 한 동네에 대한 재인증 로직만 추가된다고 가정했을 때는 아래 플로우로 갈 것 같습니다~
- 동네 인증을 한 번도 안했으면 create
- 해당 동에 인증을 한 사용자면 날짜 업데이트,
- 다른 동에 이미 인증을 한 사용자면 에러
.memberId(memberEntity.getId()) | ||
.verifiedDate(Collections.singletonList(LocalDate.now())) | ||
.build() | ||
)); |
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.
P3:
요거 요런 식으로 메서드로 빼도 좋을 것 같아요 (그냥 제안입니다잉)
private VerifiedAreaEntity updateVerifiedAreaEntity(VerifiedAreaEntity entity, LocalDate currentDate) {
VerifiedArea verifiedArea = verifiedAreaMapper.toDomain(entity);
verifiedArea.updateVerifiedDate(currentDate);
return verifiedAreaRepository.save(verifiedAreaMapper.toEntity(verifiedArea));
}
private VerifiedAreaEntity createVerifiedAreaEntity(String legalDong, Long memberId, LocalDate currentDate) {
return verifiedAreaRepository.save(
VerifiedAreaEntity.builder()
.name(legalDong)
.memberId(memberId)
.verifiedDate(Collections.singletonList(currentDate))
.build()
);
}
LocalDate currentDate = LocalDate.now();
VerifiedAreaEntity savedVerifiedAreaEntity = optionalVerifiedAreaEntity
.map(entity -> updateVerifiedAreaEntity(entity, currentDate))
.orElseGet(() -> createVerifiedAreaEntity(legalDong, memberEntity.getId(), currentDate));
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.
훨씬 명시적인 것 같아 수정했습니다! 796cdfa
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.
고생하셨습니다 ~! 어푸어푸 🌊🌊
💡 Issue
📸 Screenshot
📄 Description