package dev;

import dev.dao.MenuItemDao;
import dev.dao.OrderDao;
import dev.dao.OrderDetailDao;
import dev.dao.UserDao;
import dev.database.DatabaseConnection;
import dev.service.AuthService;
import dev.service.MenuService;
import dev.service.OrderService;
import dev.ui.ConsoleMenu;

import java.sql.Connection;

public class Main
{
    public static void main(String[] args)
    {
        try
        {
            Connection connection = DatabaseConnection.getConnection();

            UserDao userDao = new UserDao(connection);
            MenuItemDao menuItemDao = new MenuItemDao(connection);
            OrderDao orderDao = new OrderDao(connection);
            OrderDetailDao orderDetailDao = new OrderDetailDao(connection);

            AuthService authService = new AuthService(userDao);
            MenuService menuService = new MenuService(menuItemDao);
            OrderService orderService = new OrderService(
                    orderDao,
                    orderDetailDao,
                    menuItemDao
            );

            ConsoleMenu menu = new ConsoleMenu(
                    authService,
                    menuService,
                    orderService
            );

            menu.start();

        }
        catch (Exception e) {System.out.println("Application error: " + e.getMessage());}
    }
}