-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
refactor: 리더의 모임 미션 조회 쿼리 리팩토링 (#41)
- Loading branch information
Showing
3 changed files
with
25 additions
and
27 deletions.
There are no files selected for viewing
17 changes: 16 additions & 1 deletion
17
src/main/java/com/dnd/snappy/domain/mission/repository/MissionRepository.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 |
---|---|---|
@@ -1,14 +1,29 @@ | ||
package com.dnd.snappy.domain.mission.repository; | ||
|
||
import com.dnd.snappy.domain.mission.dto.response.LeaderMeetingMissionDetailResponseDto; | ||
import com.dnd.snappy.domain.mission.entity.Mission; | ||
|
||
import java.util.List; | ||
import java.util.Optional; | ||
|
||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.data.jpa.repository.Query; | ||
import org.springframework.data.repository.query.Param; | ||
|
||
public interface MissionRepository extends JpaRepository<Mission, Long> { | ||
|
||
Optional<Mission> findByIdAndMeetingId(Long id, Long meetingId); | ||
|
||
List<Mission> findAllByMeetingId(Long meetingId); | ||
} | ||
|
||
@Query(""" | ||
SELECT new com.dnd.snappy.domain.mission.dto.response.LeaderMeetingMissionDetailResponseDto(m.id, m.content, | ||
CASE WHEN mp.id IS NOT NULL THEN TRUE ELSE FALSE END) | ||
FROM Mission m | ||
LEFT JOIN MissionParticipant mp ON mp.mission.id = m.id | ||
JOIN Participant p ON p.meeting.id = m.meeting.id | ||
WHERE p.id = :participantId AND p.role = 'LEADER' AND m.meeting.id = :meetingId | ||
""") | ||
List<LeaderMeetingMissionDetailResponseDto> findLeaderMeetingMissions(@Param("meetingId") Long meetingId, @Param("participantId") Long participantId); | ||
|
||
} |
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