From 12fc4e035f0e74acdf0c9d84af1b68309fcb3271 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=8B=A0=EA=B4=80=EA=B7=9C?= Date: Sat, 18 Jan 2025 02:16:23 +0900 Subject: [PATCH] =?UTF-8?q?chore:=20=EB=A6=AC=EB=B7=B0=EB=B0=98=EC=98=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/owner/service/AdminOwnerService.java | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/src/main/java/in/koreatech/koin/admin/owner/service/AdminOwnerService.java b/src/main/java/in/koreatech/koin/admin/owner/service/AdminOwnerService.java index 66ebc2d16..3d55e6e6c 100644 --- a/src/main/java/in/koreatech/koin/admin/owner/service/AdminOwnerService.java +++ b/src/main/java/in/koreatech/koin/admin/owner/service/AdminOwnerService.java @@ -2,8 +2,6 @@ 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; @@ -23,7 +21,6 @@ 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; @@ -83,15 +80,12 @@ public AdminNewOwnersResponse getNewOwners(OwnersCondition ownersCondition) { List ownerIncludingShops = new ArrayList<>(); for (Owner owner : result.getContent()) { - Optional 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); - } - } + Shop shop = adminOwnerShopRedisRepository.findById(owner.getId()) + .map(ownerShop -> { + Integer shopId = ownerShop.getShopId(); + return shopId != null ? adminShopRepository.findById(shopId).orElse(null) : null; + }) + .orElse(null); OwnerIncludingShop ownerIncludingShop = OwnerIncludingShop.of(owner, shop); ownerIncludingShops.add(ownerIncludingShop);