1515import java .util .Optional ;
1616
1717public interface PotRepository extends JpaRepository <Pot , Long > {
18- Page <Pot > findByRecruitmentDetails_RecruitmentRole (Role recruitmentRole , Pageable pageable );
19-
2018 Optional <Pot > findPotWithRecruitmentDetailsByPotId (Long potId );
2119
2220 List <Pot > findByPotApplication_User_Id (Long userId );
2321
24- List <Pot > findByUserId (Long userId );
25-
2622 Page <Pot > findAll (Pageable pageable );
2723
2824 List <Pot > findByPotMembers_UserIdAndPotStatusOrderByCreatedAtDesc (Long userId , String status );
2925
3026 List <Pot > findByUserIdAndPotStatus (Long userId , String status );
3127
32- Page <Pot > findByUserIdAndPotStatus (Long userId , String potStatus , Pageable pageable );
28+ @ Query ("SELECT p FROM Pot p WHERE p.user.id = :userId AND p.potStatus = :potStatus ORDER BY p.createdAt DESC" )
29+ Page <Pot > findByUserIdAndPotStatusOrderByCreatedAtDesc (@ Param ("userId" ) Long userId ,
30+ @ Param ("potStatus" ) String potStatus ,
31+ Pageable pageable );
3332
3433 @ Query ("SELECT p FROM Pot p " +
3534 "WHERE LOWER(p.potName) LIKE LOWER(CONCAT('%', :keyword, '%')) " +
@@ -49,33 +48,26 @@ public interface PotRepository extends JpaRepository<Pot, Long> {
4948 "SELECT pm FROM PotMember pm WHERE pm.pot = p AND pm.user.id = :userId)" )
5049 List <Pot > findCompletedPotsByUserId (@ Param ("userId" ) Long userId );
5150
52- List <Pot > findByPotMembers_User_Id (Long potMembersUserId );
53-
5451 @ Query ("SELECT p FROM Pot p WHERE p.user.id = :userId AND p.potStatus = 'COMPLETED' AND (:cursor IS NULL OR p.potId < :cursor) ORDER BY p.potId DESC" )
5552 List <Pot > findCompletedPotsCreatedByUser (@ Param ("userId" ) Long userId , @ Param ("cursor" ) Long cursor );
5653
57- @ Modifying
58- @ Query ("DELETE FROM Pot f WHERE f.user.id = :userId" )
59- void deleteByUserId (@ Param ("userId" ) Long userId );
60- // @Modifying
61- // @Query("DELETE FROM Pot p WHERE p.user.id = :userId AND p.potId IN :potIds AND p.potStatus = 'RECRUITING'")
62- // void deleteByUserIdAndPotIds(@Param("userId") Long userId, @Param("potIds") List<Long> potIds);
6354 boolean existsByUserId (Long userId );
6455
6556 // 지원자 수 기준으로 모든 Pot 정렬
6657 @ Query ("SELECT p FROM Pot p LEFT JOIN PotApplication pa ON p = pa.pot " +
58+ "WHERE p.potStatus = :potStatus " +
6759 "GROUP BY p " +
68- "ORDER BY COUNT(pa.applicationId) DESC, p.createdAt DESC " )
69- Page <Pot > findAllOrderByApplicantsCountDesc (Pageable pageable );
60+ "ORDER BY p.createdAt DESC, COUNT(pa.applicationId) DESC " )
61+ Page <Pot > findAllOrderByApplicantsCountDesc (@ Param ( "potStatus" ) String potStatus , Pageable pageable );
7062
7163 /// 여러 Role을 기준으로 지원자 수 많은 순 정렬
7264 @ Query ("SELECT p FROM Pot p " +
7365 "LEFT JOIN PotRecruitmentDetails prd ON p = prd.pot " +
7466 "LEFT JOIN PotApplication pa ON p = pa.pot " +
75- "WHERE prd.recruitmentRole IN :roles " +
67+ "WHERE prd.recruitmentRole IN :roles AND p.potStatus = :potStatus " +
7668 "GROUP BY p " +
77- "ORDER BY COUNT(pa.applicationId) DESC, p.createdAt DESC " )
78- Page <Pot > findByRecruitmentRolesInOrderByApplicantsCountDesc (@ Param ("roles" ) List <Role > roles , Pageable pageable );
69+ "ORDER BY p.createdAt DESC, COUNT(pa.applicationId) DESC " )
70+ Page <Pot > findByRecruitmentRolesInOrderByApplicantsCountDesc (@ Param ("roles" ) List <Role > roles , @ Param ( "potStatus" ) String potStatus , Pageable pageable );
7971
8072 List <Pot > findByPotMembers_UserIdOrderByCreatedAtDesc (Long userId );
8173
0 commit comments