-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BE] 미팅 생성 #102
[BE] 미팅 생성 #102
Conversation
49a58d4
to
0a23d7a
Compare
0a23d7a
to
0bb83d0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
잘 봤습니다!
private void createSchedules(final String moimTitle, final MeetingJpaEntity meetingJpaEntity) { | ||
List<Long> memberIds = joinedMeetingFinder.findAllMemberId(meetingJpaEntity.getId()); | ||
List<CompletableFuture<Void>> futures = new ArrayList<>(); | ||
|
||
for (long memberId : memberIds) { | ||
CompletableFuture<Void> future = CompletableFuture.runAsync(() -> { | ||
ScheduleJpaEntity scheduleJpaEntity = ScheduleJpaEntity.toEntity(memberId, moimTitle, meetingJpaEntity); | ||
scheduleAppender.createSchedule(scheduleJpaEntity); | ||
}); | ||
|
||
futures.add(future); | ||
} | ||
|
||
CompletableFuture.allOf(futures.toArray(new CompletableFuture[0])).join(); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
비동기로 처리하는 부분이 인상깊네여
class JoinedMeetingManagerTest extends ImplementTest { | ||
|
||
@Autowired | ||
private JoinedMeetingAppender joinedMeetingAppender; | ||
|
||
@DisplayName("모임 참여자를 바탕으로 미팅 참여 정보를 추가한다.") | ||
@Test | ||
void saveJoinedMeeting() { | ||
// given | ||
long moimId = 1L; | ||
long meetingId = 2L; | ||
|
||
for (long i = 0; i < 3; i++) { | ||
JoinedMoimJpaEntity joinedMoimJpaEntity = JoinedMoimJpaEntity.builder() | ||
.memberId(i) | ||
.moimId(moimId) | ||
.build(); | ||
|
||
joinedMoimRepository.save(joinedMoimJpaEntity); | ||
} | ||
|
||
// when | ||
joinedMeetingAppender.saveJoinedMeeting(moimId, meetingId); | ||
|
||
// then | ||
assertThat(joinedMeetingRepository.count()).isEqualTo(3); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
JoinedMeetingManager 테스트인데 Appender 만 쓰고있고, JoinedMeetingManager 파일이 기존과, 생성된 것이 없는 것 같은데 한번 확인 부탁드려요!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
헉 그러게요 ㅋㅋㅋ 삭제하겠습니당
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 잘봣습니당
for (long memberId : memberIds) { | ||
JoinedMeetingJpaEntity joinedMeetingJpaEntity = | ||
JoinedMeetingJpaEntity.toEntity(meetingId, memberId, true); | ||
joinedMeetingRepository.save(joinedMeetingJpaEntity); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이러면 조회된 ID만큼 save가 날라갈 것 같은데, saveAll을 호출하는게 좋을 것 같습니당
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
네넹 수정하는게 좋을 것 같네용
private void createSingleMeeting(final MeetingCreateRequest meetingCreateRequest, final String moimTitle) { | ||
MeetingJpaEntity meetingJpaEntity = meetingCreateRequest.toEntity( | ||
meetingCreateRequest.startDateTime(), | ||
meetingCreateRequest.endDateTime() | ||
); | ||
|
||
meetingAppender.saveMeeting(meetingJpaEntity); | ||
joinedMeetingAppender.saveJoinedMeeting(meetingCreateRequest.moimId(), meetingJpaEntity.getId()); | ||
createSchedules(moimTitle, meetingJpaEntity); | ||
} | ||
|
||
private void createRegularMeeting(final MeetingCreateRequest meetingCreateRequest, final String moimTitle) { | ||
MoimDateResponse moimDateResponse = moimFinder.findMoimDate(meetingCreateRequest.moimId()); | ||
LocalDate startDate = moimDateResponse.startDate(); | ||
LocalDate endDate = moimDateResponse.endDate(); | ||
|
||
LocalTime startTime = meetingCreateRequest.startDateTime().toLocalTime(); | ||
LocalTime endTime = meetingCreateRequest.endDateTime().toLocalTime(); | ||
|
||
for (LocalDate date = startDate; !date.isAfter(endDate); date = date.plusWeeks(ONE_WEEK.time())) { | ||
LocalDateTime startDateTime = LocalDateTime.of(date, startTime); | ||
LocalDateTime endDateTime = LocalDateTime.of(date, endTime); | ||
|
||
MeetingJpaEntity meetingJpaEntity = meetingCreateRequest.toEntity(startDateTime, endDateTime); | ||
meetingAppender.saveMeeting(meetingJpaEntity); | ||
joinedMeetingAppender.saveJoinedMeeting(meetingCreateRequest.moimId(), meetingJpaEntity.getId()); | ||
createSchedules(moimTitle, meetingJpaEntity); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이부분 전체 트랜잭션을 고민해봐야 할것 같습니다.
전체 트랜잭션을 안 걸게되면 롤백 시 중복 저장이 될 수 도 있을 것 같습니다.
일정 생성시 겹치는 일정이 있으면 예외를 던지지 않고 넘어가고 전체적으로 트랜잭션을 걸어야 할 것 같습니당.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
네넵 예외처리 발생할 때 비동기로 그냥 넘어가도록 했는데 중간에 예외 발생할 수도 있을 것 같아서 하나로 묶을게용
4ee58bf
to
5c7f6e2
Compare
#️⃣연관된 이슈
📝작업 내용
💬리뷰 요구사항(선택)