Skip to content

Commit

Permalink
[fix] 기본 이미지 정책 변경에 따른 좋아요 식당 목록 조희 api 수정 (#162)
Browse files Browse the repository at this point in the history
* [fix] delete fetch join with storeimage entity

* [fix] add logic for get store image url

* update submodule

* [refac] use maked method
  • Loading branch information
kgy1008 authored Aug 14, 2024
1 parent 657a60c commit 5af8660
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion server-yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ public record UserHeartedStoreListResponse(
List<UserHeartedStoreViewResponse> stores
) {
public static UserHeartedStoreListResponse of(List<Heart> hearts) {
return new UserHeartedStoreListResponse(hearts.stream()
return new UserHeartedStoreListResponse(
hearts.stream()
.map(heart -> UserHeartedStoreViewResponse.of(heart.getStore()))
.toList());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public interface HeartRepository extends JpaRepository<Heart, Long> {
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<Heart> findAllWithStoreByUserId(Long userId);
}

0 comments on commit 5af8660

Please sign in to comment.