diff --git a/src/main/java/com/dnd/snappy/domain/mission/repository/MissionRepository.java b/src/main/java/com/dnd/snappy/domain/mission/repository/MissionRepository.java index 3f2374c..a877dee 100644 --- a/src/main/java/com/dnd/snappy/domain/mission/repository/MissionRepository.java +++ b/src/main/java/com/dnd/snappy/domain/mission/repository/MissionRepository.java @@ -5,6 +5,7 @@ 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; @@ -15,11 +16,14 @@ public interface MissionRepository extends JpaRepository { List findAllByMeetingId(Long meetingId); - @Query("SELECT new com.dnd.snappy.domain.mission.dto.response.LeaderMeetingMissionDetailResponseDto(m.id, m.content, " + - "EXISTS (SELECT 1 FROM MissionParticipant mp WHERE mp.mission.id = m.id)) " + - "FROM Mission m " + - "JOIN Participant p ON p.meeting.id = m.meeting.id " + - "WHERE p.id = :participantId AND p.role = 'LEADER' AND m.meeting.id = :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 findLeaderMeetingMissions(@Param("meetingId") Long meetingId, @Param("participantId") Long participantId); } \ No newline at end of file