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

[FIX/#82] 이미 인증된 동네가 존재할 때 동네 인증 재진행 시 예외 처리 추가 #83

Merged
merged 6 commits into from
Feb 16, 2025

Conversation

gahyuun
Copy link
Collaborator

@gahyuun gahyuun commented Feb 15, 2025

💡 Issue

📸 Screenshot

image

📄 Description

  1. 현재 기획상으로는 사용자마다 인증된 동네를 한 개씩 가지고 있기 때문에, 동네인증 API 호출 시 이미 인증한 동네가 존재하면 에러를 반환하도록 수정하였습니다. 이후 배포시에는 동네를 이미 여러 번 가지고 있는 사용자의 데이터를 수정할 예정입니당.
  2. 동네 인증 API Response 수정
  3. 로그인 시 동네 인증 여부 필드를 추가하였습니다

@gahyuun gahyuun added the 🛠️ FIX 버그, 오류 등을 수정 label Feb 15, 2025
@gahyuun gahyuun self-assigned this Feb 15, 2025
@gahyuun gahyuun requested a review from ckkim817 as a code owner February 15, 2025 16:41
@gahyuun gahyuun added the size/S label Feb 15, 2025
Copy link
Member

@ckkim817 ckkim817 left a 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();
}
Copy link
Member

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);
}

이런 느낌?

Copy link
Collaborator Author

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);
}
Copy link
Member

Choose a reason for hiding this comment

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

Q2:

요거 추후 한 동네에 대한 재인증 로직이 추가되면 어떻게 수정할 예정이신가요 ?!

Copy link
Collaborator Author

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()
));
Copy link
Member

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));

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

훨씬 명시적인 것 같아 수정했습니다! 796cdfa

Copy link
Member

@ckkim817 ckkim817 left a comment

Choose a reason for hiding this comment

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

고생하셨습니다 ~! 어푸어푸 🌊🌊

@gahyuun gahyuun merged commit 8e224c0 into develop Feb 16, 2025
1 check passed
@gahyuun gahyuun deleted the fix/#82 branch February 16, 2025 07:01
@ckkim817 ckkim817 changed the title [FIX/#82] 중복 동네 인증 에러 수정 [FIX/#82] 이미 인증된 동네가 존재할 때 동네 인증 재진행 시 에러 처리 Feb 18, 2025
@ckkim817 ckkim817 changed the title [FIX/#82] 이미 인증된 동네가 존재할 때 동네 인증 재진행 시 에러 처리 [FIX/#82] 이미 인증된 동네가 존재할 때 동네 인증 재진행 시 에러 처리 추가 Feb 18, 2025
@ckkim817 ckkim817 changed the title [FIX/#82] 이미 인증된 동네가 존재할 때 동네 인증 재진행 시 에러 처리 추가 [FIX/#82] 이미 인증된 동네가 존재할 때 동네 인증 재진행 시 예외 처리 추가 Feb 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🛠️ FIX 버그, 오류 등을 수정 size/S 🦊 가현
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FIX] 이미 인증된 동네가 존재할 때 동네 인증 재진행 시 예외 처리 추가
2 participants