package org.example.demo.praktikum6;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public class TestClient implements CommandLineRunner {

    @Autowired
    private AutoDAO autoDAO;

    @Autowired
    private LogEntryDAO logEntryDAO;

    @Override
    public void run(String... args) {
        // 1c)
        autoDAO.createAuto("BMW", "E32", "NE-IN 0000");

        List<LogEntry> logs = logEntryDAO.getAllLogEntries();
        System.out.println("=== Log-Einträge (" + logs.size() + ") ===");
        for (LogEntry entry : logs) {
            System.out.println("[" + entry.time + "] " + entry.message);
        }

        // 1d)
        autoDAO.createAuto("Mercedes", "AMG", "");

        List<LogEntry> newLogs = logEntryDAO.getAllLogEntries();
        System.out.println("=== Log-Einträge (" + logs.size() + ") ===");
        for (LogEntry entry : logs) {
            System.out.println("[" + entry.time + "] " + entry.message);
        }
    }
}
