Skip to content

Commit

Permalink
fix: findLeaderMeetingMissions query fix
Browse files Browse the repository at this point in the history
  • Loading branch information
abc5259 committed Aug 24, 2024
1 parent 51461c0 commit 102501d
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,9 @@ public interface MissionRepository extends JpaRepository<Mission, Long> {
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
LEFT JOIN MissionParticipant mp ON mp.mission.id = m.id
WHERE m.meeting.id = :meetingId
""")
List<LeaderMeetingMissionDetailResponseDto> findLeaderMeetingMissions(@Param("meetingId") Long meetingId, @Param("participantId") Long participantId);
List<LeaderMeetingMissionDetailResponseDto> findLeaderMeetingMissions(@Param("meetingId") Long meetingId);

}
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public List<LeaderMeetingMissionDetailResponseDto> findLeaderMeetingMissions(Lon
findByMeetingIdOrThrow(meetingId);
missionValidationService.validateIsLeader(participantId, meetingId);

return missionRepository.findLeaderMeetingMissions(meetingId, participantId);
return missionRepository.findLeaderMeetingMissions(meetingId);
}

private Meeting findByMeetingIdOrThrow(Long meetingId) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,20 @@ void findLeaderMeetingMissions() throws Exception {
Meeting meeting = createMeeting();
Participant leader = createParticipant(meeting, Role.LEADER);
Participant participant = createParticipant(meeting, Role.PARTICIPANT);
Participant participant2 = createParticipant(meeting, Role.PARTICIPANT);

Mission mission = Mission.builder()
.meeting(meeting)
.content("미션 내용")
.build();
missionRepository.save(mission);

Mission mission2 = Mission.builder()
.meeting(meeting)
.content("미션 내용2")
.build();
missionRepository.save(mission2);

MissionParticipant missionParticipant = MissionParticipant.builder()
.participant(participant)
.mission(mission)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ void findLeaderMeetingMissions() {
given(meetingRepository.findById(meetingId)).willReturn(Optional.of(meeting));
doNothing().when(missionValidationService).validateIsLeader(participantId, meetingId);

given(missionRepository.findLeaderMeetingMissions(meetingId, participantId)).willReturn(
given(missionRepository.findLeaderMeetingMissions(meetingId)).willReturn(
List.of(
new LeaderMeetingMissionDetailResponseDto(1L, "미션 내용 1", false),
new LeaderMeetingMissionDetailResponseDto(2L, "미션 내용 2", false),
Expand Down

0 comments on commit 102501d

Please sign in to comment.