package com.social.media.interfaces.web.controller;

import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.time.LocalDateTime;
import java.util.Map;

/**
 * Main REST Controller for general API operations
 */
@RestController
@RequestMapping("/api/v1")
public class MainController {
    
    /**
     * API health check
     */
    @GetMapping("/health")
    public ResponseEntity<Map<String, Object>> health() {
        return ResponseEntity.ok(Map.of(
            "status", "UP",
            "timestamp", LocalDateTime.now(),
            "service", "Social Media Manager API",
            "version", "1.0.0"
        ));
    }
    
    /**
     * API information
     */
    @GetMapping("/info")
    public ResponseEntity<Map<String, Object>> info() {
        return ResponseEntity.ok(Map.of(
            "name", "Social Media Manager API",
            "description", "Clean Architecture + Hexagonal + CQRS implementation",
            "version", "1.0.0",
            "architecture", "Clean + Hexagonal + CQRS",
            "patterns", Map.of(
                "domain", "DDD (Domain-Driven Design)",
                "application", "CQRS (Command Query Responsibility Segregation)",
                "infrastructure", "JPA/Hibernate + Spring Data",
                "interface", "REST API + DTOs"
            ),
            "contexts", Map.of(
                "total", 7,
                "list", new String[]{
                    "Company", "User", "SocialNetwork", 
                    "SocialAccount", "Content", "Bot", "Analytics"
                }
            )
        ));
    }
    
    /**
     * API status with detailed information
     */
    @GetMapping("/status")
    public ResponseEntity<Map<String, Object>> status() {
        return ResponseEntity.ok(Map.of(
            "api", "operational",
            "database", "connected", 
            "services", Map.of(
                "company", "active",
                "user", "active", 
                "socialNetwork", "active",
                "socialAccount", "active",
                "content", "active",
                "bot", "active",
                "analytics", "active"
            ),
            "timestamp", LocalDateTime.now()
        ));
    }
}
