diff --git a/src/main/java/com/dnd/jjakkak/domain/meeting/repository/MeetingRepositoryImpl.java b/src/main/java/com/dnd/jjakkak/domain/meeting/repository/MeetingRepositoryImpl.java index 907e27a..232126e 100644 --- a/src/main/java/com/dnd/jjakkak/domain/meeting/repository/MeetingRepositoryImpl.java +++ b/src/main/java/com/dnd/jjakkak/domain/meeting/repository/MeetingRepositoryImpl.java @@ -10,6 +10,7 @@ import com.dnd.jjakkak.domain.meeting.entity.QMeeting; import com.dnd.jjakkak.domain.meeting.enums.MeetingSort; import com.dnd.jjakkak.domain.meetingcategory.entity.QMeetingCategory; +import com.dnd.jjakkak.domain.member.entity.QMember; import com.dnd.jjakkak.domain.schedule.entity.QSchedule; import com.querydsl.core.types.OrderSpecifier; import com.querydsl.core.types.Projections; @@ -196,14 +197,16 @@ public MeetingParticipantResponseDto getParticipant(String uuid) { @Override public boolean existsByMemberIdAndMeetingUuid(Long memberId, String meetingUuid) { - QMeeting meeting = QMeeting.meeting; QSchedule schedule = QSchedule.schedule; + QMeeting meeting = QMeeting.meeting; + QMember member = QMember.member; return from(schedule) .join(schedule.meeting, meeting) + .join(schedule.member, member) .where(meeting.meetingUuid.eq(meetingUuid) - .and(schedule.member.memberId.eq(memberId))) - .select(schedule.count()) - .fetchOne() > 0; + .and(member.memberId.eq(memberId))) + .fetchCount() > 0; + } } diff --git a/src/main/java/com/dnd/jjakkak/domain/meetingmember/service/MeetingMemberService.java b/src/main/java/com/dnd/jjakkak/domain/meetingmember/service/MeetingMemberService.java index 1d3287e..4f466d8 100644 --- a/src/main/java/com/dnd/jjakkak/domain/meetingmember/service/MeetingMemberService.java +++ b/src/main/java/com/dnd/jjakkak/domain/meetingmember/service/MeetingMemberService.java @@ -47,13 +47,16 @@ public void createMeetingMemberBySchedule(Long scheduleId, Long memberId) { Schedule schedule = scheduleRepository.findById(scheduleId) .orElseThrow(ScheduleNotFoundException::new); - MeetingMember meetingMember = MeetingMember.builder() - .pk(pk) - .member(member) - .meeting(schedule.getMeeting()) - .build(); - - meetingMemberRepository.save(meetingMember); + // 이미 리더는 모임을 생성할 때 회원으로 추가되어 있으므로 제외 + if (!schedule.getMeeting().getMeetingLeaderId().equals(memberId)) { + MeetingMember meetingMember = MeetingMember.builder() + .pk(pk) + .member(member) + .meeting(schedule.getMeeting()) + .build(); + + meetingMemberRepository.save(meetingMember); + } } /**