Skip to content

Commit

Permalink
Merge pull request #78 from LikeKNU/feature/MainMenuWithMealType
Browse files Browse the repository at this point in the history
Feat: 메인 ν™”λ©΄ 식단에 mealType μΆ”κ°€
  • Loading branch information
ahma0 authored Nov 22, 2023
2 parents ce8f624 + e39e725 commit 9f392bd
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import ac.knu.likeknu.controller.dto.menu.MenuListDto;
import ac.knu.likeknu.domain.Cafeteria;
import ac.knu.likeknu.domain.value.CafeteriaName;
import ac.knu.likeknu.domain.value.MealType;
import lombok.Builder;
import lombok.Getter;

Expand All @@ -14,12 +14,14 @@ public class MainMenuResponse {

private final String cafeteriaId;
private final String cafeteriaName;
private final String mealType;
private final List<MenuListDto> menus;

@Builder
public MainMenuResponse(String cafeteriaId, String cafeteriaName, List<MenuListDto> menus) {
public MainMenuResponse(String cafeteriaId, String cafeteriaName, String mealType, List<MenuListDto> menus) {
this.cafeteriaId = cafeteriaId;
this.cafeteriaName = cafeteriaName;
this.mealType = mealType;
this.menus = menus;
}

Expand All @@ -35,6 +37,7 @@ public static MainMenuResponse of(Cafeteria cafeteria, String menu) {
return MainMenuResponse.builder()
.cafeteriaId(cafeteria.getId())
.cafeteriaName(cafeteria.getCafeteriaName().getCafeteriaName())
.mealType(MealType.now().getMealTypeKr())
.menus(menuList)
.build();
}
Expand All @@ -43,6 +46,7 @@ public static MainMenuResponse empty(Cafeteria cafeteria) {
return MainMenuResponse.builder()
.cafeteriaId(cafeteria.getId())
.cafeteriaName(cafeteria.getCafeteriaName().getCafeteriaName())
.mealType(MealType.now().getMealTypeKr())
.menus(new ArrayList<>())
.build();
}
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/ac/knu/likeknu/domain/value/MealType.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ public enum MealType {
BREAKFAST("μ•„μΉ¨", 9),
LUNCH("점심", 14),
DINNER("저녁", 19),
NIGHT("", 21),
DAWN("", 0);
NIGHT("λ°€", 21),
DAWN("μƒˆλ²½", 2);

private final String mealTypeKr;
private final int hour;
Expand All @@ -27,7 +27,7 @@ public static MealType now() {

return Stream.of(MealType.values())
.filter((MealType m) -> m.getHour() > hour)
.findAny()
.orElse(DAWN);
.findFirst()
.orElse(NIGHT);
}
}
12 changes: 5 additions & 7 deletions src/test/java/ac/knu/likeknu/controller/MainControllerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@
import static org.mockito.Mockito.when;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;

@Slf4j
@DisplayName("메인 컨트둀러 ν…ŒμŠ€νŠΈ")
Expand Down Expand Up @@ -144,10 +142,10 @@ void getMenuResponsesAndSuccess() throws Exception {
new MenuListDto(2, "testMenu2")
);

MainMenuResponse menuResponse1 = new MainMenuResponse("cafeteriaId1", "학생식당", menus);
MainMenuResponse menuResponse2 = new MainMenuResponse("cafeteriaId2", "μƒν™œκ΄€μ‹λ‹Ή", menus);
MainMenuResponse menuResponse3 = new MainMenuResponse("cafeteriaId2", "μƒν™œκ΄€μ‹λ‹Ή", menus);
MainMenuResponse menuResponse4 = new MainMenuResponse("cafeteriaId3", "직원식당", menus);
MainMenuResponse menuResponse1 = new MainMenuResponse("cafeteriaId1", "학생식당", "μ•„μΉ¨", menus);
MainMenuResponse menuResponse2 = new MainMenuResponse("cafeteriaId2", "μƒν™œκ΄€μ‹λ‹Ή", "점심", menus);
MainMenuResponse menuResponse3 = new MainMenuResponse("cafeteriaId2", "μƒν™œκ΄€μ‹λ‹Ή", "저녁", menus);
MainMenuResponse menuResponse4 = new MainMenuResponse("cafeteriaId3", "직원식당", "μ•„μΉ¨", menus);

List<MainMenuResponse> menuResponses1 = new ArrayList<>(List.of(menuResponse1, menuResponse2, menuResponse4));
List<MainMenuResponse> menuResponses2 = new ArrayList<>(List.of(menuResponse1, menuResponse3, menuResponse4));
Expand Down

0 comments on commit 9f392bd

Please sign in to comment.