package com.ruemu.springops.config;

import com.ruemu.springops.model.ServiceRequest;
import com.ruemu.springops.repository.ServiceRequestRepository;
import org.springframework.boot.CommandLineRunner;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class SeedData {
    @Bean
    CommandLineRunner seed(ServiceRequestRepository repo) {
        return args -> {
            if (repo.count() > 0) return;
            String[][] rows = {
                {"Acme Health", "Payment Reconciliation", "COMPLETED", "1"},
                {"Northstar Labs", "Document Delivery", "PROCESSING", "2"},
                {"BrightPath", "Account Verification", "PENDING", "2"},
                {"Helios Group", "Notification Batch", "COMPLETED", "3"},
                {"Lumen Care", "Billing Update", "FAILED", "1"},
                {"Atlas Services", "Secure File Export", "PROCESSING", "2"}
            };
            for (String[] row : rows) {
                ServiceRequest r = new ServiceRequest();
                r.setCustomer(row[0]); r.setServiceType(row[1]);
                r.setStatus(ServiceRequest.Status.valueOf(row[2])); r.setPriority(Integer.parseInt(row[3]));
                repo.save(r);
            }
        };
    }
}
