Skip to content

Commit

Permalink
Merge pull request #99 from LikeKNU/develop
Browse files Browse the repository at this point in the history
fix: 다음날 식단 메뉴에 operatingTime이 현재 날짜 기준이었음
  • Loading branch information
jcw1031 authored Mar 3, 2024
2 parents f912ffa + 6bf26c2 commit cc316b0
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 18 deletions.
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
plugins {
id 'java'
id 'org.springframework.boot' version '3.1.3'
id 'io.spring.dependency-management' version '1.1.3'
id 'org.springframework.boot' version '3.2.3'
id 'io.spring.dependency-management' version '1.1.4'
}

group = 'ac.knu'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

import java.time.LocalDate;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

@Getter
Expand Down Expand Up @@ -40,7 +41,7 @@ public static MealListDto of(MealType mealType, Cafeteria cafeteria, Menu menu)

return MealListDto.builder()
.mealType(mealType.getMealTypeKr())
.operatingTime(cafeteria.getTime(mealType))
.operatingTime(cafeteria.getTime(mealType, menu.getMenuDate()))
.menus(menuList)
.date(menu.getMenuDate())
.build();
Expand All @@ -49,7 +50,7 @@ public static MealListDto of(MealType mealType, Cafeteria cafeteria, Menu menu)
public static MealListDto empty(MealType mealType, LocalDate date) {
return MealListDto.builder()
.mealType(mealType.getMealTypeKr())
.menus(new ArrayList<>())
.menus(Collections.emptyList())
.date(date)
.build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,4 @@ public static MenuResponse of(Cafeteria cafeteria, Map<LocalDate, List<MealListD
.tomorrow(mealList.get(keys.get(1)))
.build();
}

}
23 changes: 11 additions & 12 deletions src/main/java/ac/knu/likeknu/domain/Cafeteria.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import lombok.Builder;
import lombok.Getter;

import java.time.LocalDateTime;
import java.time.LocalDate;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
Expand Down Expand Up @@ -66,32 +66,31 @@ public Cafeteria(CafeteriaName cafeteriaName, String weekdayBreakfast, String we
this.campus = campus;
}

public String getTime(MealType mealType) {
if(mealType == null)
public String getTime(MealType mealType, LocalDate date) {
if (mealType == null)
return null;

if(isWeekend()) {
if (isWeekend(date)) {
//주말일 때
if(isBreakfast(mealType))
if (isBreakfast(mealType))
return weekendBreakfast;
else if(isLunch(mealType))
else if (isLunch(mealType))
return weekendLunch;
else
return weekendDinner;
}
else {
} else {
//평일일 때
if(isBreakfast(mealType))
if (isBreakfast(mealType))
return weekdayBreakfast;
else if(isLunch(mealType))
else if (isLunch(mealType))
return weekdayLunch;
else
return weekdayDinner;
}
}

private boolean isWeekend() {
return LocalDateTime.now().getDayOfWeek().getValue() >= 6;
private boolean isWeekend(LocalDate date) {
return date.getDayOfWeek().getValue() >= 6;
}

private boolean isBreakfast(MealType mealType) {
Expand Down
1 change: 0 additions & 1 deletion src/main/java/ac/knu/likeknu/service/MenuService.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,4 @@ private MealListDto findRepositoryAndMapDto(MealType mealType, Cafeteria cafeter
.map(menu -> MealListDto.of(mealType, cafeteria, menu))
.orElse(MealListDto.empty(mealType, date));
}

}

0 comments on commit cc316b0

Please sign in to comment.