diff --git a/src/main/java/side/onetime/dto/event/response/GetMostPossibleTime.java b/src/main/java/side/onetime/dto/event/response/GetMostPossibleTime.java index defc48b..75b331b 100644 --- a/src/main/java/side/onetime/dto/event/response/GetMostPossibleTime.java +++ b/src/main/java/side/onetime/dto/event/response/GetMostPossibleTime.java @@ -41,8 +41,8 @@ public static GetMostPossibleTime dateOf(Schedule schedule, List possibl ); } - public void updateEndTime(String endTime) { - new GetMostPossibleTime( + public GetMostPossibleTime updateEndTime(String endTime) { + return new GetMostPossibleTime( this.timePoint, this.startTime, addThirtyMinutes(endTime), diff --git a/src/main/java/side/onetime/service/EventService.java b/src/main/java/side/onetime/service/EventService.java index 2b23aa1..c004c12 100644 --- a/src/main/java/side/onetime/service/EventService.java +++ b/src/main/java/side/onetime/service/EventService.java @@ -224,13 +224,17 @@ private List buildMostPossibleTimes(Map curNames = entry.getValue(); if (curNames.size() == mostPossibleCnt) { + // 이전 시간대와 병합 가능한 경우 if (canMergeWithPrevious(previousTime, schedule, curNames, category)) { - previousTime.updateEndTime(schedule.getTime()); + // 종료 시간을 더해 업데이트 + previousTime = previousTime.updateEndTime(schedule.getTime()); + mostPossibleTimes.set(mostPossibleTimes.size() - 1, previousTime); } else { List impossibleNames = allMembersName.stream() .filter(name -> !curNames.contains(name)) .toList(); + // 새로운 시간대를 추가 GetMostPossibleTime newTime = createMostPossibleTime(schedule, curNames, impossibleNames, category); mostPossibleTimes.add(newTime); previousTime = newTime;