Skip to content

Commit

Permalink
fix: 새로운 사장님 리스트 조회 로직 버그 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
Soundbar91 committed Jan 17, 2025
1 parent 71d1391 commit b15c796
Showing 1 changed file with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.Optional;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
Expand All @@ -21,6 +23,7 @@
import in.koreatech.koin.admin.user.repository.AdminUserRepository;
import in.koreatech.koin.domain.owner.model.Owner;
import in.koreatech.koin.domain.owner.model.OwnerIncludingShop;
import in.koreatech.koin.domain.owner.model.OwnerShop;
import in.koreatech.koin.domain.shop.model.shop.Shop;
import in.koreatech.koin.domain.user.model.UserType;
import in.koreatech.koin.global.model.Criteria;
Expand Down Expand Up @@ -80,9 +83,15 @@ public AdminNewOwnersResponse getNewOwners(OwnersCondition ownersCondition) {

List<OwnerIncludingShop> ownerIncludingShops = new ArrayList<>();
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 (ownerShop.getShopId() != null) {
shop = adminShopRepository.findById(ownerShop.getShopId()).orElse(null);
}
}

OwnerIncludingShop ownerIncludingShop = OwnerIncludingShop.of(owner, shop);
ownerIncludingShops.add(ownerIncludingShop);
Expand Down

0 comments on commit b15c796

Please sign in to comment.