Skip to content

초대장 저장 기능 구현 완료 (알림톡 기능 추가 전)#39

Merged
khsrla9806 merged 10 commits into
livable-final:developfrom
khsrla9806:feature/#31-create-invitation
Sep 19, 2023
Merged

초대장 저장 기능 구현 완료 (알림톡 기능 추가 전)#39
khsrla9806 merged 10 commits into
livable-final:developfrom
khsrla9806:feature/#31-create-invitation

Conversation

@khsrla9806
Copy link
Copy Markdown
Contributor

@khsrla9806 khsrla9806 commented Sep 18, 2023



  • 면접은 1명만 초대가 가능한 제한 조건

    private void checkInterviewVisitorCount(InvitationRequest.CreateDTO dto) {
        if (dto.getPurpose().equals(InvitationPurpose.INTERVIEW.getValue())
                && dto.getVisitors().size() > INTERVIEW_MAXIMUM_COUNT) {
            throw new GlobalRuntimeException(InvitationErrorCode.INVALID_INTERVIEW_MAXIMUM_NUMBER);
        }
    }
  • 입력으로 들어온 공용장소(commonPlaceId)에 입력된 날짜, 시간 범위에 대한 예약 정보 개수를 가져옴

    private int getExpectedReservationCount(LocalDateTime startDateTime, LocalDateTime endDateTime) {
        LocalDate startDate = startDateTime.toLocalDate();
        LocalDate endDate = endDateTime.toLocalDate();
        LocalTime startTime = startDateTime.toLocalTime();
        LocalTime endTime = endDateTime.toLocalTime();
    
        int dayCount = (int) Duration.between(startDate.atStartOfDay(), endDate.atStartOfDay()).toDays() + 1;
        int timeCount = (endTime.toSecondOfDay() - startTime.toSecondOfDay()) / 1800;
    
        return dayCount * timeCount;
    }
    • 입력된 CommonPlaceId와 시작 날짜, 종료 날짜로 가져온 예약 정보의 개수와 동일한지 확인하기 위해서 사용
    • 개수가 다르면 해당 공용장소에 대한 잘못된 예약 시간을 요청한 것으로 판단
  • CommonPlaceId, 시작 날짜, 종료 날짜로 해당하는 모든 예약 정보를 가져오는 쿼리 메서드 구현

    public List<Reservation> findReservationsByCommonPlaceIdAndStartDateAndEndDate(
            Long commonPlaceId, LocalDateTime startDateTime, LocalDateTime endDateTime
    ) {
    
        return queryFactory
                .selectFrom(reservation)
                .where(
                        reservation.commonPlace.id.eq(commonPlaceId),
                        reservation.date.between(
                                startDateTime.toLocalDate(),
                                endDateTime.toLocalDate()
                        ),
                        reservation.time.between(
                                startDateTime.toLocalTime(),
                                endDateTime.toLocalTime().minusMinutes(30)
                        ),
                        reservation.id.notIn(
                                JPAExpressions
                                        .select(invitationReservationMap.reservation.id)
                                        .from(invitationReservationMap)
                                        .where(invitationReservationMap.reservation.id.eq(reservation.id))
                        )
                )
                .orderBy(reservation.date.asc(), reservation.time.asc())
                .fetch();
    }
    • 이미 예약된 예약 정보들은 In Query로 제거함
  • 모든 조건이 맞다면 초대장(Invitation), 방문자(Visitors), 예약정보(InvitationReservationMap)를 저장

@khsrla9806 khsrla9806 added the develop 기능 개발 label Sep 18, 2023
@khsrla9806 khsrla9806 self-assigned this Sep 18, 2023
@khsrla9806 khsrla9806 merged commit 5dd926b into livable-final:develop Sep 19, 2023
@khsrla9806 khsrla9806 deleted the feature/#31-create-invitation branch October 6, 2023 01:33
@khsrla9806 khsrla9806 added the review 코드 리뷰 요청 label Oct 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

develop 기능 개발 review 코드 리뷰 요청

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant