Skip to content

Commit

Permalink
Merge branch 'common/dev/refactor-presentation-date#1691' of github.c…
Browse files Browse the repository at this point in the history
…om:innovationacademy-kr/Cabi into common/dev/refactor-presentation-date#1691
  • Loading branch information
jihyunk03 committed Oct 29, 2024
2 parents 384211f + 2d01aa7 commit f391c74
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package org.ftclub.cabinet.presentation.domain;

public enum PresentationStatus {
CANCEL, DONE, EXPECTED
CANCEL, DONE, EXPECTED, DUMMY
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@ List<Presentation> findAllByDateTimeBetweenOrderByDateTime(LocalDateTime start,

List<Presentation> findAllByDateTimeBetween(LocalDateTime start, LocalDateTime end);

List<Presentation> findPresentationByDateTimeBetween(LocalDateTime startOfDate,
LocalDateTime endOfDate);

@Query("SELECT p "
+ "FROM Presentation p "
+ "WHERE p.user.id = :userId")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ public List<Presentation> getRegisteredPresentations(LocalDateTime start, LocalD
return presentations.stream()
.filter(presentation ->
!presentation.getPresentationStatus().equals(PresentationStatus.CANCEL)
&& !presentation.getCategory().equals(Category.DUMMY)
&& !presentation.getPresentationStatus()
.equals(PresentationStatus.DUMMY)
)
.collect(Collectors.toList());
}
Expand All @@ -43,11 +44,13 @@ public List<Presentation> getPresentationsByYearMonth(YearMonth yearMonth) {
endDayDate);
}

public Presentation getPresentationsByDate(LocalDateTime dateTime) {
public Presentation getOneByDate(LocalDateTime dateTime) {
LocalDateTime startOfDate = dateTime.withHour(0).withMinute(0).withSecond(0);
LocalDateTime endOfDate = dateTime.withHour(23).withMinute(59).withSecond(59);
return presentationRepository.findPresentationByDateTimeBetween(startOfDate, endOfDate)
.stream().filter(p -> p.getPresentationStatus() != PresentationStatus.CANCEL)
return presentationRepository.findAllByDateTimeBetween(startOfDate, endOfDate)
.stream()
.filter(p -> p.getPresentationStatus() != PresentationStatus.CANCEL)
.filter(p -> p.getPresentationStatus() != PresentationStatus.DUMMY)
.findFirst()
.orElseThrow(ExceptionStatus.INVALID_PRESENTATION_DATE::asServiceException);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ public class PresentationService {
public void createPresentationForm(Long userId, PresentationFormRequestDto dto) {
presentationPolicyService.verifyReservationDate(dto.getDateTime());

Presentation presentation = presentationQueryService.getPresentationsByDate(
dto.getDateTime());
Presentation presentation =
presentationQueryService.getOneByDate(dto.getDateTime());

presentation.updateDummyToUserForm(dto.getCategory(),
dto.getPresentationTime(), dto.getDateTime(),
Expand Down

0 comments on commit f391c74

Please sign in to comment.