package com.example.bricklog;

import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;

import com.example.bricklog.model.LegoBuild;
import com.example.bricklog.repository.LegoBuildRepository;

@SpringBootApplication
@EnableJpaRepositories(basePackages = "com.example.bricklog.repository") // Adjust if needed
public class BrickLogApplication {

    public static void main(String[] args) {
        SpringApplication.run(BrickLogApplication.class, args);
        System.out.println("BrickLog Server is running...");
    }

        // Example CommandLineRunner to load initial data into the database
    @Bean
    public CommandLineRunner initDatabase(LegoBuildRepository repository) {
        return args -> {
            repository.save(new LegoBuild("Castle", "John Doe", true, "A magnificent medieval castle"));
            repository.save(new LegoBuild("Spaceship", "Jane Smith", false, "A futuristic spacecraft model"));
            System.out.println("Database initialized with sample data.");
        };
    }
}
