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: 새로운 사장님 조회 로직 버그 수정 #1182

Merged
merged 4 commits into from
Jan 18, 2025

Conversation

Soundbar91
Copy link
Contributor

🔥 연관 이슈

🚀 작업 내용

  • 새로운 사장님 조회 로직 버그를 수정했습니다.
    • 사장님 회원가입 과정에서 등록되지 않는 가게는 shopid가 null로 저장됩니다.
    • findById 메소드에 null 값이 들어가서 어드민 페이지에서 500 에러가 발생했습니다.

💬 리뷰 중점사항

@Soundbar91 Soundbar91 added the 버그 정상적으로 동작하지 않는 문제상황입니다. label Jan 17, 2025
@Soundbar91 Soundbar91 self-assigned this Jan 17, 2025
Copy link
Contributor

@20HyeonsuLee 20HyeonsuLee left a comment

Choose a reason for hiding this comment

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

빠른 대응 👍👍

Comment on lines 85 to 97
for (Owner owner : result.getContent()) {
Shop shop = adminOwnerShopRedisRepository.findById(owner.getId())
.map(ownerShop -> adminShopRepository.findById(ownerShop.getShopId()).orElse(null))
.orElse(null);
Optional<OwnerShop> ownerShopOptional = adminOwnerShopRedisRepository.findById(owner.getId());
Shop shop = null;

if (ownerShopOptional.isPresent()) {
OwnerShop ownerShop = ownerShopOptional.get();
if (!Objects.isNull(ownerShop.getShopId())) {
shop = adminShopRepository.findById(ownerShop.getShopId()).orElse(null);
}
}

OwnerIncludingShop ownerIncludingShop = OwnerIncludingShop.of(owner, shop);
ownerIncludingShops.add(ownerIncludingShop);
Copy link
Contributor

Choose a reason for hiding this comment

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

A

요런건 어떠한지

Suggested change
for (Owner owner : result.getContent()) {
Shop shop = adminOwnerShopRedisRepository.findById(owner.getId())
.map(ownerShop -> adminShopRepository.findById(ownerShop.getShopId()).orElse(null))
.orElse(null);
Optional<OwnerShop> ownerShopOptional = adminOwnerShopRedisRepository.findById(owner.getId());
Shop shop = null;
if (ownerShopOptional.isPresent()) {
OwnerShop ownerShop = ownerShopOptional.get();
if (!Objects.isNull(ownerShop.getShopId())) {
shop = adminShopRepository.findById(ownerShop.getShopId()).orElse(null);
}
}
OwnerIncludingShop ownerIncludingShop = OwnerIncludingShop.of(owner, shop);
ownerIncludingShops.add(ownerIncludingShop);
List<OwnerIncludingShop> ownerIncludingShops = new ArrayList<>();
for (Owner owner : result.getContent()) {
Shop shop = adminOwnerShopRedisRepository.findById(owner.getId())
.map(ownerShop -> {
Long shopId = ownerShop.getShopId();
return shopId != null ? adminShopRepository.findById(shopId).orElse(null) : null;
})
.orElse(null);
OwnerIncludingShop ownerIncludingShop = OwnerIncludingShop.of(owner, shop);
ownerIncludingShops.add(ownerIncludingShop);
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

if문 주렁주렁 달려있는 거 보다 보기 좋네요 👍

Copy link

github-actions bot commented Jan 17, 2025

Unit Test Results

354 tests   353 ✔️  1m 32s ⏱️
  45 suites      1 💤
  45 files        0

Results for commit 12fc4e0.

♻️ This comment has been updated with latest results.

@Soundbar91 Soundbar91 merged commit 6833d20 into develop Jan 18, 2025
4 checks passed
@Soundbar91 Soundbar91 deleted the fix/1181-new-owners-logic branch January 18, 2025 03:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
버그 정상적으로 동작하지 않는 문제상황입니다.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

새로운 사장님 리스트 조회 버그를 고친다
3 participants