Skip to content

Commit fd72c03

Browse files
committed
style: 쿼리 통일
1 parent de2ceec commit fd72c03

File tree

1 file changed

+20
-20
lines changed

1 file changed

+20
-20
lines changed

src/main/java/com/oronaminc/join/participant/dao/ParticipantRepository.java

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@
1515

1616
public interface ParticipantRepository extends JpaRepository<Participant, Long> {
1717

18-
@Query(
19-
"SELECT COUNT(p) > 0 " +
20-
"FROM Participant p " +
21-
"WHERE p.room.id = :roomId AND p.member.id = :memberId"
22-
)
18+
@Query("""
19+
select COUNT(p) > 0
20+
from Participant p
21+
where p.room.id = :roomId and p.member.id = :memberId
22+
""")
2323
boolean existsByRoomIdAndMemberId(@Param("roomId") Long roomId, @Param("memberId") Long memberId);
2424

2525
Optional<Participant> findByRoomIdAndParticipantType(Long roomId, ParticipantType participantType);
@@ -30,23 +30,23 @@ public interface ParticipantRepository extends JpaRepository<Participant, Long>
3030
from Participant p
3131
where p.member.id = :memberId
3232
group by p.participantType
33-
""")
33+
""")
3434
List<ParticipantCountDto> countByMemberIdGroupByParticipantType(Long memberId);
3535

3636
@Query("""
3737
select p
3838
from Participant p
3939
join fetch p.room
4040
where p.member.id = :memberId
41-
""")
41+
""")
4242
Page<Participant> findByMemberId(Long memberId, Pageable pageable);
4343

4444
@Query("""
4545
select p
4646
from Participant p
4747
join fetch p.room
4848
where p.member.id = :memberId and p.participantType = :pType
49-
""")
49+
""")
5050
Page<Participant> findByMemberIdAndParticipantType(Long memberId, ParticipantType pType,
5151
Pageable pageable);
5252

@@ -55,30 +55,30 @@ Page<Participant> findByMemberIdAndParticipantType(Long memberId, ParticipantTyp
5555
from Participant p
5656
join fetch p.room
5757
where p.member.id = :memberId and p.participantType != :pType
58-
""")
58+
""")
5959
Page<Participant> findByMemberIdAndParticipantTypeNot(Long memberId, ParticipantType pType,
6060
Pageable pageable);
6161

6262
Optional<Participant> findByRoomIdAndMemberId( @Param("roomId") Long roomId, @Param("memberId") Long memberId );
6363

6464
@Query("""
65-
SELECT CASE WHEN COUNT(p) > 0 THEN true ELSE false END
66-
FROM Participant p
67-
WHERE p.room.id = :roomId
68-
AND p.member.id = :memberId
69-
AND (p.participantType = com.oronaminc.join.participant.domain.ParticipantType.PRESENTER
70-
OR p.participantType = com.oronaminc.join.participant.domain.ParticipantType.TEAM)
65+
select case when COUNT(p) > 0 then true else false end
66+
from Participant p
67+
where p.room.id = :roomId
68+
and p.member.id = :memberId
69+
and (p.participantType = com.oronaminc.join.participant.domain.ParticipantType.PRESENTER
70+
or p.participantType = com.oronaminc.join.participant.domain.ParticipantType.TEAM)
7171
""")
7272
boolean existsPresenterOrTeamByMemberId(@Param("roomId") Long roomId, @Param("memberId") Long memberId);
7373

7474
void deleteByRoomId(Long roomId);
7575

7676
@Query(value = """
77-
SELECT COUNT(*)
78-
FROM participant
79-
WHERE room_id = :roomId
80-
AND exited_at IS NOT NULL
81-
AND TIMESTAMPDIFF(SECOND, created_at, exited_at) >= 30
77+
select COUNT(*)
78+
from participant
79+
where room_id = :roomId
80+
and exited_at is not null
81+
and TIMESTAMPDIFF(SECOND, created_at, exited_at) >= 30
8282
""", nativeQuery = true)
8383
Long countParticipantsStayedOver30Seconds(@Param("roomId") Long roomId);
8484
}

0 commit comments

Comments
 (0)