Skip to content

Commit

Permalink
Merge pull request #132 from dnd-side-project/feature/#130-meeting
Browse files Browse the repository at this point in the history
[Feature] 일정 한눈에 보기
  • Loading branch information
f1v3-dev authored Oct 11, 2024
2 parents 67ccc81 + 6bdbf04 commit c668116
Show file tree
Hide file tree
Showing 5 changed files with 95 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public ResponseEntity<MeetingInfoResponseDto> getMeetingInfo(@PathVariable("meet
*
* @param uuid 조회할 모임 UUID
* @param pageable 페이징 정보 (default: page = 0, size = 10, sort = count)
* @return 200 (OK), body: 모임 시간 응답 DTO
* @return 200 (OK), body: 모임 시간 응답 DTO (페이징 처리)
*/
@GetMapping("/{meetingUuid}/times")
public ResponseEntity<PagedResponse<MeetingTimeResponseDto>> getMeetingTimes(
Expand All @@ -85,13 +85,26 @@ public ResponseEntity<PagedResponse<MeetingTimeResponseDto>> getMeetingTimes(
return ResponseEntity.ok(responseDto);
}

/**
* 모임의 전체 일정을 조회하는 메서드입니다.
*
* @param uuid 조회할 모임 UUID
* @return 200 (OK), body: 모임 시간 응답 DTO
*/
@GetMapping("/{meetingUuid}/times/all")
public ResponseEntity<MeetingTimeResponseDto> getMeetingAllTimes(@PathVariable("meetingUuid") String uuid) {

MeetingTimeResponseDto responseDto = meetingService.getMeetingAllTimes(uuid);
return ResponseEntity.ok(responseDto);
}

/**
* 모임의 최적 시간을 조회하는 메서드입니다.
*
* @param uuid 조회할 모임 UUID
* @return 200 (OK), body: 최적 시간
*/
@GetMapping("/{meetingUuid}/best-time")
@GetMapping("/{meetingUuid}/times/best")
public ResponseEntity<LocalDateTime> getBestTime(@PathVariable("meetingUuid") String uuid) {
return ResponseEntity.ok(meetingService.getBestTime(uuid));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,12 @@ public interface MeetingRepositoryCustom {
* @return 최적의 시간
*/
LocalDateTime getBestTime(String uuid);

/**
* 모임의 UUID로 전체 일정을 조회합니다.
*
* @param uuid 모임 UUId
* @return 모임 시간 응답 DTO
*/
MeetingTimeResponseDto getMeetingAllTimes(String uuid);
}
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ public MeetingInfoResponseDto getMeetingInfo(String uuid) {
@Override
public PagedResponse<MeetingTimeResponseDto> getMeetingTimes(String uuid, Pageable pageable, LocalDateTime requestTime) {

// TODO : 성능 개선 필요해보임
QMeeting meeting = QMeeting.meeting;
QSchedule schedule = QSchedule.schedule;
QDateOfSchedule dateOfSchedule = QDateOfSchedule.dateOfSchedule;
Expand Down Expand Up @@ -272,4 +271,56 @@ public LocalDateTime getBestTime(String uuid) {
.select(dateOfSchedule.dateOfScheduleStart)
.fetchFirst();
}

/**
* {@inheritDoc}
*/
@Override
public MeetingTimeResponseDto getMeetingAllTimes(String uuid) {

QMeeting meeting = QMeeting.meeting;
QSchedule schedule = QSchedule.schedule;
QDateOfSchedule dateOfSchedule = QDateOfSchedule.dateOfSchedule;

// 빠른 시간 순으로 조회
List<MeetingTime> meetingTimeList = from(dateOfSchedule)
.join(dateOfSchedule.schedule, schedule)
.join(schedule.meeting, meeting)
.where(meeting.meetingUuid.eq(uuid))
.groupBy(dateOfSchedule.dateOfScheduleStart, dateOfSchedule.dateOfScheduleEnd)
.orderBy(dateOfSchedule.dateOfScheduleStart.asc())
.select(Projections.constructor(MeetingTime.class,
dateOfSchedule.dateOfScheduleStart,
dateOfSchedule.dateOfScheduleEnd,
dateOfSchedule.dateOfScheduleRank.avg()
))
.fetch();

for (MeetingTime meetingTime : meetingTimeList) {
List<String> nicknames = from(dateOfSchedule)
.join(dateOfSchedule.schedule, schedule)
.join(schedule.meeting, meeting)
.where(meeting.meetingUuid.eq(uuid)
.and(dateOfSchedule.dateOfScheduleStart.eq(meetingTime.getStartTime()))
.and(dateOfSchedule.dateOfScheduleEnd.eq(meetingTime.getEndTime())))
.select(schedule.scheduleNickname)
.fetch();

meetingTime.addMemberNames(nicknames);
}

MeetingTimeResponseDto responseDto = from(meeting)
.where(meeting.meetingUuid.eq(uuid))
.select(Projections.constructor(MeetingTimeResponseDto.class,
meeting.numberOfPeople,
meeting.isAnonymous,
meeting.meetingStartDate,
meeting.meetingEndDate
))
.fetchOne();

responseDto.addMeetingTimeList(meetingTimeList);

return responseDto;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ public MeetingCreateResponseDto createMeeting(Long memberId, MeetingCreateReques
}

// 모임 생성 시 인원 수 만큼 기본 일정을 생성합니다.
// TODO: 개선할 수 있는 방법 찾아보기
for (int i = 0; i < meeting.getNumberOfPeople(); i++) {
scheduleService.createDefaultSchedule(meeting);
}
Expand Down Expand Up @@ -193,11 +192,29 @@ public MeetingParticipantResponseDto getParticipants(String uuid) {
return meetingRepository.getParticipant(uuid);
}

/**
* 모임의 최적 시간을 조회합니다.
*
* @param uuid 조회할 모임 UUID
* @return 모임의 최적 시간 1개
*/
@Transactional(readOnly = true)
public LocalDateTime getBestTime(String uuid) {
return meetingRepository.getBestTime(uuid);
}


/**
* 모임의 전체 일정을 조회합니다.
*
* @param uuid 조회할 모임 UUID
* @return 모임의 전체 일정 응답 DTO
*/
@Transactional(readOnly = true)
public MeetingTimeResponseDto getMeetingAllTimes(String uuid) {
return meetingRepository.getMeetingAllTimes(uuid);
}

/**
* UUID를 생성하는 메서드입니다.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,10 @@ public class SecurityEndpointPaths {
"/api/v1/auth/oauth/**",
"/api/v1/auth/**",
"/api/v1/meetings/*/info",
"/api/v1/meetings/*/times",
"/api/v1/meetings/*/times/**",
"/api/v1/meetings/*/participants",
"/api/v1/meetings/*/schedules/guests/**",
"/api/v1/meetings/*/schedules/*",
"/api/v1/meetings/*/best-time",
"/api/v1/meetings/*/schedules/*"
};

public static final String[] USER_LIST = {
Expand Down

0 comments on commit c668116

Please sign in to comment.