package com.social.media.dto;

import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;

import java.time.LocalDateTime;
import java.util.Map;

public class BotDto {
    
    private String id;
    
    @NotBlank(message = "Nome é obrigatório")
    @Size(max = 100, message = "Nome deve ter no máximo 100 caracteres")
    private String name;
    
    @Size(max = 500, message = "Descrição deve ter no máximo 500 caracteres")
    private String description;
    
    @NotNull(message = "Tipo é obrigatório")
    private String type;
    
    private Boolean active;
    private String userId;
    private LocalDateTime createdAt;
    private LocalDateTime updatedAt;
    private LocalDateTime lastExecutionAt;
    private BotConfigDto config;
    private ExecutionStatsDto stats;
    
    public BotDto() {}
    
    public BotDto(String id, String name, String description, String type, Boolean active) {
        this.id = id;
        this.name = name;
        this.description = description;
        this.type = type;
        this.active = active;
        this.createdAt = LocalDateTime.now();
    }
    
    public static class BotConfigDto {
        private String schedule;
        private Boolean autoRestart;
        private Integer maxExecutions;
        private Map<String, Object> parameters;
        
        public BotConfigDto() {}
        
        // Getters and Setters
        public String getSchedule() { return schedule; }
        public void setSchedule(String schedule) { this.schedule = schedule; }
        
        public Boolean getAutoRestart() { return autoRestart; }
        public void setAutoRestart(Boolean autoRestart) { this.autoRestart = autoRestart; }
        
        public Integer getMaxExecutions() { return maxExecutions; }
        public void setMaxExecutions(Integer maxExecutions) { this.maxExecutions = maxExecutions; }
        
        public Map<String, Object> getParameters() { return parameters; }
        public void setParameters(Map<String, Object> parameters) { this.parameters = parameters; }
    }
    
    public static class ExecutionStatsDto {
        private Integer totalExecutions;
        private Integer successfulExecutions;
        private Integer failedExecutions;
        private LocalDateTime lastSuccessAt;
        private LocalDateTime lastFailureAt;
        private String lastError;
        
        public ExecutionStatsDto() {}
        
        public ExecutionStatsDto(Integer totalExecutions, Integer successfulExecutions, Integer failedExecutions) {
            this.totalExecutions = totalExecutions;
            this.successfulExecutions = successfulExecutions;
            this.failedExecutions = failedExecutions;
        }
        
        // Getters and Setters
        public Integer getTotalExecutions() { return totalExecutions; }
        public void setTotalExecutions(Integer totalExecutions) { this.totalExecutions = totalExecutions; }
        
        public Integer getSuccessfulExecutions() { return successfulExecutions; }
        public void setSuccessfulExecutions(Integer successfulExecutions) { this.successfulExecutions = successfulExecutions; }
        
        public Integer getFailedExecutions() { return failedExecutions; }
        public void setFailedExecutions(Integer failedExecutions) { this.failedExecutions = failedExecutions; }
        
        public LocalDateTime getLastSuccessAt() { return lastSuccessAt; }
        public void setLastSuccessAt(LocalDateTime lastSuccessAt) { this.lastSuccessAt = lastSuccessAt; }
        
        public LocalDateTime getLastFailureAt() { return lastFailureAt; }
        public void setLastFailureAt(LocalDateTime lastFailureAt) { this.lastFailureAt = lastFailureAt; }
        
        public String getLastError() { return lastError; }
        public void setLastError(String lastError) { this.lastError = lastError; }
    }
    
    // Getters and Setters
    public String getId() { return id; }
    public void setId(String id) { this.id = id; }
    
    public String getName() { return name; }
    public void setName(String name) { this.name = name; }
    
    public String getDescription() { return description; }
    public void setDescription(String description) { this.description = description; }
    
    public String getType() { return type; }
    public void setType(String type) { this.type = type; }
    
    public Boolean getActive() { return active; }
    public void setActive(Boolean active) { this.active = active; }
    
    public String getUserId() { return userId; }
    public void setUserId(String userId) { this.userId = userId; }
    
    public LocalDateTime getCreatedAt() { return createdAt; }
    public void setCreatedAt(LocalDateTime createdAt) { this.createdAt = createdAt; }
    
    public LocalDateTime getUpdatedAt() { return updatedAt; }
    public void setUpdatedAt(LocalDateTime updatedAt) { this.updatedAt = updatedAt; }
    
    public LocalDateTime getLastExecutionAt() { return lastExecutionAt; }
    public void setLastExecutionAt(LocalDateTime lastExecutionAt) { this.lastExecutionAt = lastExecutionAt; }
    
    public BotConfigDto getConfig() { return config; }
    public void setConfig(BotConfigDto config) { this.config = config; }
    
    public ExecutionStatsDto getStats() { return stats; }
    public void setStats(ExecutionStatsDto stats) { this.stats = stats; }
}
