Skip to content

Commit

Permalink
Merge pull request #109 from onetime-with-members/feature/#108/array
Browse files Browse the repository at this point in the history
[feat] : 고정 스케줄 조회 시, 시간을 오름차순 정렬하여 반환한다
  • Loading branch information
bbbang105 authored Nov 3, 2024
2 parents 339d700 + 0824514 commit 04f1f6a
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions src/main/java/side/onetime/service/FixedScheduleService.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import side.onetime.util.JwtUtil;

import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
Expand Down Expand Up @@ -65,11 +66,17 @@ public List<FixedEventResponse> getAllFixedSchedules(String authorizationHeader)

List<FixedEventResponse> fixedEventResponses = new ArrayList<>();
for (FixedEvent fixedEvent : fixedEvents) {
// 각 이벤트에 대한 고정 선택을 그룹화하여 요일별 스케줄을 생성
// 각 이벤트에 대한 고정 선택을 그룹화하여 요일별 스케줄을 생성 (times를 오름차순 정렬)
Map<String, List<String>> groupedSchedules = fixedEvent.getFixedSelections().stream()
.collect(Collectors.groupingBy(
selection -> selection.getFixedSchedule().getDay(),
Collectors.mapping(selection -> selection.getFixedSchedule().getTime(), Collectors.toList())
Collectors.collectingAndThen(
Collectors.mapping(selection -> selection.getFixedSchedule().getTime(), Collectors.toList()),
list -> {
list.sort(Comparator.naturalOrder());
return list;
}
)
));

// 고정 스케줄 정보 생성
Expand All @@ -96,11 +103,17 @@ public FixedEventDetailResponse getFixedScheduleDetail(String authorizationHeade
throw new CustomException(FixedErrorStatus._NOT_FOUND_FIXED_EVENT);
}

// 고정 선택을 요일별로 그룹화하여 시간 목록을 생성
// 고정 선택을 요일별로 그룹화하여 시간 목록을 생성 (times를 오름차순 정렬)
Map<String, List<String>> groupedSchedules = fixedEvent.getFixedSelections().stream()
.collect(Collectors.groupingBy(
selection -> selection.getFixedSchedule().getDay(),
Collectors.mapping(selection -> selection.getFixedSchedule().getTime(), Collectors.toList())
Collectors.collectingAndThen(
Collectors.mapping(selection -> selection.getFixedSchedule().getTime(), Collectors.toList()),
list -> {
list.sort(Comparator.naturalOrder());
return list;
}
)
));

// 고정 스케줄 정보 생성
Expand Down

0 comments on commit 04f1f6a

Please sign in to comment.