Skip to content

Commit

Permalink
[BE] refactor : 참여 목록 저장시 saveAll 메소드로 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
320Hwany committed May 4, 2024
1 parent 0a2414f commit 5c7f6e2
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import moim_today.persistence.repository.meeting.joined_meeting.JoinedMeetingRepository;
import org.springframework.transaction.annotation.Transactional;

import java.util.ArrayList;
import java.util.List;

@Implement
Expand All @@ -23,11 +24,13 @@ public JoinedMeetingAppender(final JoinedMeetingRepository joinedMeetingReposito
@Transactional
public void saveJoinedMeeting(final long moimId, final long meetingId) {
List<Long> memberIds = joinedMoimFinder.findAllJoinedMemberId(moimId);
List<JoinedMeetingJpaEntity> joinedMeetings = new ArrayList<>();

for (long memberId : memberIds) {
JoinedMeetingJpaEntity joinedMeetingJpaEntity =
JoinedMeetingJpaEntity.toEntity(meetingId, memberId, true);
joinedMeetingRepository.save(joinedMeetingJpaEntity);
JoinedMeetingJpaEntity joinedMeeting = JoinedMeetingJpaEntity.toEntity(meetingId, memberId, true);
joinedMeetings.add(joinedMeeting);
}

joinedMeetingRepository.saveAll(joinedMeetings);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ public interface JoinedMeetingRepository {

void save(final JoinedMeetingJpaEntity joinedMeetingJpaEntity);

void saveAll(final List<JoinedMeetingJpaEntity> joinedMeetingJpaEntities);

List<Long> findAllMemberIdByMeetingId(final long meetingId);

List<JoinedMeetingJpaEntity> findAll();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ public void save(final JoinedMeetingJpaEntity joinedMeetingJpaEntity) {
joinedMeetingJpaRepository.save(joinedMeetingJpaEntity);
}

@Override
public void saveAll(final List<JoinedMeetingJpaEntity> joinedMeetingJpaEntities) {
joinedMeetingJpaRepository.saveAll(joinedMeetingJpaEntities);
}

@Override
public List<Long> findAllMemberIdByMeetingId(final long meetingId) {
return queryFactory.select(joinedMeetingJpaEntity.memberId)
Expand Down

0 comments on commit 5c7f6e2

Please sign in to comment.