Package edu.ucsb.cs156.dining.services
Class MenuItemService
java.lang.Object
edu.ucsb.cs156.dining.services.MenuItemService
Service for interacting with the Dining Menu API and saving menu items.
-
Constructor Summary
ConstructorsConstructorDescriptionMenuItemService(org.springframework.boot.web.client.RestTemplateBuilder restTemplateBuilder, MenuItemRepository menuItemRepository) -
Method Summary
Modifier and TypeMethodDescriptiongetMenuItems(LocalDateTime dateTime, String diningCommonsCode, String mealCode) Fetches all menu items for a specific dining commons, meal, and date.saveOrUpdateMenuItem(MenuItem menuItem, String diningCommonsCode, String mealCode) Saves the menu item to the database if it does not already exist.
-
Constructor Details
-
MenuItemService
public MenuItemService(org.springframework.boot.web.client.RestTemplateBuilder restTemplateBuilder, MenuItemRepository menuItemRepository)
-
-
Method Details
-
getMenuItems
public List<MenuItemDTO> getMenuItems(LocalDateTime dateTime, String diningCommonsCode, String mealCode) Fetches all menu items for a specific dining commons, meal, and date. Saves each unique menu item to the database.- Parameters:
dateTime- the date as LocalDateTimediningCommonsCode- the code for the dining commonsmealCode- the meal code (e.g., "breakfast", "lunch", "dinner")- Returns:
- a list of MenuItemDTO containing name, station, and id
-
saveOrUpdateMenuItem
Saves the menu item to the database if it does not already exist.- Parameters:
menuItem- the menu item retrieved from the APIdiningCommonsCode- the dining commons codemealCode- the meal code- Returns:
- the saved or existing MenuItem
-