From 5af8660ccd87ce6175319c8edf69b277b95018d5 Mon Sep 17 00:00:00 2001 From: kgy1008 Date: Wed, 14 Aug 2024 15:27:13 +0900 Subject: [PATCH] =?UTF-8?q?[fix]=20=EA=B8=B0=EB=B3=B8=20=EC=9D=B4=EB=AF=B8?= =?UTF-8?q?=EC=A7=80=20=EC=A0=95=EC=B1=85=20=EB=B3=80=EA=B2=BD=EC=97=90=20?= =?UTF-8?q?=EB=94=B0=EB=A5=B8=20=EC=A2=8B=EC=95=84=EC=9A=94=20=EC=8B=9D?= =?UTF-8?q?=EB=8B=B9=20=EB=AA=A9=EB=A1=9D=20=EC=A1=B0=ED=9D=AC=20api=20?= =?UTF-8?q?=EC=88=98=EC=A0=95=20(#162)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * [fix] delete fetch join with storeimage entity * [fix] add logic for get store image url * update submodule * [refac] use maked method --- server-yml | 2 +- .../user/service/response/UserHeartedStoreListResponse.java | 3 ++- .../user/service/response/UserHeartedStoreViewResponse.java | 2 +- .../hankkiserver/domain/heart/repository/HeartRepository.java | 4 ++-- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/server-yml b/server-yml index b792c34c..d1485007 160000 --- a/server-yml +++ b/server-yml @@ -1 +1 @@ -Subproject commit b792c34c7d8325341b53887497df0e45b5774fcb +Subproject commit d1485007111421cd0539cf8826ac213e090bcdc7 diff --git a/src/main/java/org/hankki/hankkiserver/api/user/service/response/UserHeartedStoreListResponse.java b/src/main/java/org/hankki/hankkiserver/api/user/service/response/UserHeartedStoreListResponse.java index 8d405eaf..198ecf3d 100644 --- a/src/main/java/org/hankki/hankkiserver/api/user/service/response/UserHeartedStoreListResponse.java +++ b/src/main/java/org/hankki/hankkiserver/api/user/service/response/UserHeartedStoreListResponse.java @@ -8,7 +8,8 @@ public record UserHeartedStoreListResponse( List stores ) { public static UserHeartedStoreListResponse of(List hearts) { - return new UserHeartedStoreListResponse(hearts.stream() + return new UserHeartedStoreListResponse( + hearts.stream() .map(heart -> UserHeartedStoreViewResponse.of(heart.getStore())) .toList()); } diff --git a/src/main/java/org/hankki/hankkiserver/api/user/service/response/UserHeartedStoreViewResponse.java b/src/main/java/org/hankki/hankkiserver/api/user/service/response/UserHeartedStoreViewResponse.java index cc8ee577..31e229ea 100644 --- a/src/main/java/org/hankki/hankkiserver/api/user/service/response/UserHeartedStoreViewResponse.java +++ b/src/main/java/org/hankki/hankkiserver/api/user/service/response/UserHeartedStoreViewResponse.java @@ -14,7 +14,7 @@ public static UserHeartedStoreViewResponse of(Store store) { return new UserHeartedStoreViewResponse( store.getId(), store.getName(), - store.getImages().get(0).getImageUrl(), + store.getImageUrlOrElseNull(), store.getCategory().getName(), store.getLowestPrice(), store.getHeartCount() diff --git a/src/main/java/org/hankki/hankkiserver/domain/heart/repository/HeartRepository.java b/src/main/java/org/hankki/hankkiserver/domain/heart/repository/HeartRepository.java index ae7d42d2..36db6ebc 100644 --- a/src/main/java/org/hankki/hankkiserver/domain/heart/repository/HeartRepository.java +++ b/src/main/java/org/hankki/hankkiserver/domain/heart/repository/HeartRepository.java @@ -13,7 +13,7 @@ public interface HeartRepository extends JpaRepository { boolean existsByUserAndStore(User user, Store store); void deleteByUserAndStore(User user, Store store); - @Query("select h from Heart h join fetch h.store s join fetch s.images " + - "where h.user.id = :userId and s.isDeleted = false order by h.id desc") + @Query("select h from Heart h join fetch h.store " + + "where h.user.id = :userId and h.store.isDeleted = false order by h.id desc") List findAllWithStoreByUserId(Long userId); }