-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#231 Refactor: 와인 리뷰 전체 조회 시, 와인 리뷰 조회 메서드와 좋아요 조회 메서드 분리
- Loading branch information
1 parent
da23806
commit 0c86e1b
Showing
10 changed files
with
57 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
src/main/java/com/drinkeg/drinkeg/repository/WineWishlistRepositoryCustom.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package com.drinkeg.drinkeg.repository; | ||
|
||
public interface WineWishlistRepositoryCustom { | ||
|
||
Boolean existsByMemberIdAndWineId(Long memberId, Long wineId); | ||
} |
33 changes: 33 additions & 0 deletions
33
src/main/java/com/drinkeg/drinkeg/repository/WineWishlistRepositoryImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package com.drinkeg.drinkeg.repository; | ||
|
||
import com.querydsl.jpa.impl.JPAQueryFactory; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Repository; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
import java.util.Optional; | ||
|
||
import static com.drinkeg.drinkeg.domain.QWineWishlist.wineWishlist; | ||
|
||
@Repository | ||
@RequiredArgsConstructor | ||
@Transactional | ||
public class WineWishlistRepositoryImpl implements WineWishlistRepositoryCustom { | ||
|
||
private final JPAQueryFactory queryFactory; | ||
|
||
|
||
@Override | ||
public Boolean existsByMemberIdAndWineId(Long memberId, Long wineId) { | ||
// wineWishlist에 해당하는 데이터가 존재하면 true, 존재하지 않으면 false | ||
Optional<Boolean> isLiked = Optional.ofNullable( | ||
queryFactory | ||
.select(wineWishlist.id.isNotNull()) // wineWishlist가 존재하는지 여부를 체크 | ||
.from(wineWishlist) | ||
.where(wineWishlist.wine.id.eq(wineId).and(wineWishlist.member.id.eq(memberId))) | ||
.fetchOne() | ||
); | ||
|
||
return isLiked.orElse(false); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters