From 8126e65a08c4f09ec1eabb435437cc0f9827bd29 Mon Sep 17 00:00:00 2001 From: seungjo Date: Wed, 25 Sep 2024 01:30:22 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=EB=AA=A8=EC=9E=84=20=EB=A6=AC=EB=8D=94?= =?UTF-8?q?=20-=20MeetingMember=20=EC=98=A4=EB=A5=98=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../repository/MeetingRepositoryImpl.java | 11 +++++++---- .../service/MeetingMemberService.java | 17 ++++++++++------- 2 files changed, 17 insertions(+), 11 deletions(-) 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); + } } /**