Class MenuItemService

java.lang.Object
edu.ucsb.cs156.dining.services.MenuItemService

@Service public class MenuItemService extends Object
Service for interacting with the Dining Menu API and saving menu items.
  • 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 LocalDateTime
      diningCommonsCode - the code for the dining commons
      mealCode - the meal code (e.g., "breakfast", "lunch", "dinner")
      Returns:
      a list of MenuItemDTO containing name, station, and id
    • saveOrUpdateMenuItem

      public MenuItem saveOrUpdateMenuItem(MenuItem menuItem, String diningCommonsCode, String mealCode)
      Saves the menu item to the database if it does not already exist.
      Parameters:
      menuItem - the menu item retrieved from the API
      diningCommonsCode - the dining commons code
      mealCode - the meal code
      Returns:
      the saved or existing MenuItem