Skip to content

Commit

Permalink
[Refactor] countQuery 조건 변경 #142
Browse files Browse the repository at this point in the history
  • Loading branch information
ashd89 committed Aug 8, 2024
1 parent 3c15853 commit 5fc5a70
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,6 @@ public List<ExchangeEntity> readExchangeOfferForMe(User user,Integer page, Integ

@Override
public Long readExchangeOfferCnt(Long userId) {
return exchangeRepository.countReservationsByUserId(userId);
return exchangeRepository.countExchangeByUserId(userId);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ public interface JpaExchangeRepository extends JpaRepository<ExchangeEntity,Long
)
List<ExchangeEntity> findExchangeByUser (Long userId, Pageable page);

@Query("SELECT COUNT(r) FROM ReservationEntity r " +
@Query("SELECT COUNT(e) FROM ExchangeEntity e "+
"JOIN e.reservation2 r " +
"JOIN r.user u " +
"WHERE u.id = :userId")
Long countReservationsByUserId(@Param("userId") Long userId);
"WHERE u.id = :userId AND e.isWatch = false")
Long countExchangeByUserId(@Param("userId") Long userId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@ public interface ReservationRepository extends JpaRepository<ReservationEntity,

@Query("SELECT COUNT(r) FROM ReservationEntity r " +
"JOIN r.user u " +
"WHERE u.id = :userId")
"WHERE u.id = :userId AND r.status='COMPLETED'")
Long countReservationsByUserId(@Param("userId") Long userId);
}

0 comments on commit 5fc5a70

Please sign in to comment.