Class OrdersSQL

java.lang.Object
csce331.group13.project2.backend.OrdersSQL

public class OrdersSQL extends Object
Provides data access methods for orders in the database. Handles creation of orders and order details.
Author:
William Clymire, Austin Glander
  • Constructor Details

    • OrdersSQL

      public OrdersSQL(Connection conn)
      Constructs an OrdersSQL instance with a database connection.
      Parameters:
      conn - An active database connection.
  • Method Details

    • createOrder

      public UUID createOrder(UUID employeeId, String customerName, BigDecimal totalCost) throws SQLException
      Creates a new order in the database and returns its generated order ID.
      Parameters:
      employeeId - The UUID of the employee creating the order.
      customerName - The name of the customer.
      totalCost - The total cost of the order.
      Returns:
      The UUID of the newly created order.
      Throws:
      SQLException - if a database error occurs or if order creation fails.
    • addOrderDetail

      public void addOrderDetail(UUID orderId, UUID menuItemId, int lineNo, int parentLineNo, int quantity) throws SQLException
      Adds a single order detail record to the database.
      Parameters:
      orderId - The UUID of the order.
      menuItemId - The UUID of the menu item.
      lineNo - The line number of this item in the order.
      parentLineNo - The parent line number (for items that are part of combos).
      quantity - The quantity of this menu item.
      Throws:
      SQLException - if a database error occurs during insertion.