Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,21 @@
public interface BookJpaRepository extends JpaRepository<BookJpaEntity, Long> {
Optional<BookJpaEntity> findByIsbn(String isbn);

@Query("SELECT DISTINCT b FROM BookJpaEntity b " +
@Query("SELECT b FROM BookJpaEntity b " +
"JOIN SavedBookJpaEntity s ON s.bookJpaEntity.bookId = b.bookId " +
"WHERE s.userJpaEntity.userId = :userId " +
"ORDER BY s.createdAt DESC")
"GROUP BY b " +
"ORDER BY MAX(s.createdAt) DESC")
List<BookJpaEntity> findSavedBooksByUserId(Long userId);

@Query("SELECT DISTINCT b FROM BookJpaEntity b " +
@Query("SELECT b FROM BookJpaEntity b " +
"JOIN RoomJpaEntity r ON r.bookJpaEntity.bookId = b.bookId " +
"JOIN RoomParticipantJpaEntity rp ON rp.roomJpaEntity.roomId = r.roomId " +
"WHERE rp.userJpaEntity.userId = :userId " +
"AND r.status = 'ACTIVE' " +
"AND r.startDate <= CURRENT_TIMESTAMP " + // 진행 중인 방만 조회 (모집 중 / 만료된 방 x)
"ORDER BY r.roomPercentage DESC") // 방의 진행률이 높은 순서로 정렬
" AND r.status = 'ACTIVE' " +
" AND r.startDate <= CURRENT_TIMESTAMP " + // 진행 중인 방만 조회 (모집 중 / 만료된 방 x)
"GROUP BY b " +
"ORDER BY MAX(r.roomPercentage) DESC") // 방의 진행률이 높은 순서로 정렬
List<BookJpaEntity> findJoiningRoomsBooksByUserId(Long userId);

boolean existsByIsbn(String isbn);
Expand Down