package com.social.media.interfaces.web.dto.analytics;

import com.fasterxml.jackson.annotation.JsonProperty;

import java.time.LocalDateTime;
import java.util.List;

/**
 * Dashboard analytics response DTO
 */
public class DashboardAnalyticsResponse {
    
    @JsonProperty("totalPosts")
    private long totalPosts;
    
    @JsonProperty("publishedPosts")
    private long publishedPosts;
    
    @JsonProperty("scheduledPosts")
    private long scheduledPosts;
    
    @JsonProperty("totalSocialAccounts")
    private long totalSocialAccounts;
    
    @JsonProperty("activeSocialAccounts")
    private long activeSocialAccounts;
    
    @JsonProperty("platformDistribution")
    private List<PlatformStatsDto> platformDistribution;
    
    @JsonProperty("accountMetrics")
    private List<AccountMetricsSummaryDto> accountMetrics;
    
    @JsonProperty("recentActivity")
    private List<ActivityLogDto> recentActivity;
    
    // Constructors
    public DashboardAnalyticsResponse() {}
    
    public DashboardAnalyticsResponse(long totalPosts, long publishedPosts, long scheduledPosts,
                                    long totalSocialAccounts, long activeSocialAccounts,
                                    List<PlatformStatsDto> platformDistribution,
                                    List<AccountMetricsSummaryDto> accountMetrics,
                                    List<ActivityLogDto> recentActivity) {
        this.totalPosts = totalPosts;
        this.publishedPosts = publishedPosts;
        this.scheduledPosts = scheduledPosts;
        this.totalSocialAccounts = totalSocialAccounts;
        this.activeSocialAccounts = activeSocialAccounts;
        this.platformDistribution = platformDistribution;
        this.accountMetrics = accountMetrics;
        this.recentActivity = recentActivity;
    }
    
    // Getters and Setters
    public long getTotalPosts() { return totalPosts; }
    public void setTotalPosts(long totalPosts) { this.totalPosts = totalPosts; }
    
    public long getPublishedPosts() { return publishedPosts; }
    public void setPublishedPosts(long publishedPosts) { this.publishedPosts = publishedPosts; }
    
    public long getScheduledPosts() { return scheduledPosts; }
    public void setScheduledPosts(long scheduledPosts) { this.scheduledPosts = scheduledPosts; }
    
    public long getTotalSocialAccounts() { return totalSocialAccounts; }
    public void setTotalSocialAccounts(long totalSocialAccounts) { this.totalSocialAccounts = totalSocialAccounts; }
    
    public long getActiveSocialAccounts() { return activeSocialAccounts; }
    public void setActiveSocialAccounts(long activeSocialAccounts) { this.activeSocialAccounts = activeSocialAccounts; }
    
    public List<PlatformStatsDto> getPlatformDistribution() { return platformDistribution; }
    public void setPlatformDistribution(List<PlatformStatsDto> platformDistribution) { this.platformDistribution = platformDistribution; }
    
    public List<AccountMetricsSummaryDto> getAccountMetrics() { return accountMetrics; }
    public void setAccountMetrics(List<AccountMetricsSummaryDto> accountMetrics) { this.accountMetrics = accountMetrics; }
    
    public List<ActivityLogDto> getRecentActivity() { return recentActivity; }
    public void setRecentActivity(List<ActivityLogDto> recentActivity) { this.recentActivity = recentActivity; }
    
    /**
     * Platform statistics DTO
     */
    public static class PlatformStatsDto {
        @JsonProperty("platform")
        private String platform;
        
        @JsonProperty("count")
        private long count;
        
        @JsonProperty("percentage")
        private double percentage;
        
        @JsonProperty("engagement")
        private double engagement;
        
        @JsonProperty("reach")
        private long reach;
        
        @JsonProperty("growth")
        private double growth;
        
        public PlatformStatsDto() {}
        
        public PlatformStatsDto(String platform, long count, double percentage, 
                               double engagement, long reach, double growth) {
            this.platform = platform;
            this.count = count;
            this.percentage = percentage;
            this.engagement = engagement;
            this.reach = reach;
            this.growth = growth;
        }
        
        // Getters and Setters
        public String getPlatform() { return platform; }
        public void setPlatform(String platform) { this.platform = platform; }
        
        public long getCount() { return count; }
        public void setCount(long count) { this.count = count; }
        
        public double getPercentage() { return percentage; }
        public void setPercentage(double percentage) { this.percentage = percentage; }
        
        public double getEngagement() { return engagement; }
        public void setEngagement(double engagement) { this.engagement = engagement; }
        
        public long getReach() { return reach; }
        public void setReach(long reach) { this.reach = reach; }
        
        public double getGrowth() { return growth; }
        public void setGrowth(double growth) { this.growth = growth; }
    }
    
    /**
     * Account metrics summary DTO
     */
    public static class AccountMetricsSummaryDto {
        @JsonProperty("socialAccountId")
        private String socialAccountId;
        
        @JsonProperty("username")
        private String username;
        
        @JsonProperty("platform")
        private String platform;
        
        @JsonProperty("totalFollowers")
        private long totalFollowers;
        
        @JsonProperty("followerGrowth")
        private double followerGrowth;
        
        @JsonProperty("totalPosts")
        private long totalPosts;
        
        @JsonProperty("avgEngagement")
        private double avgEngagement;
        
        @JsonProperty("reachRate")
        private double reachRate;
        
        @JsonProperty("lastUpdated")
        private LocalDateTime lastUpdated;
        
        public AccountMetricsSummaryDto() {}
        
        public AccountMetricsSummaryDto(String socialAccountId, String username, String platform,
                                      long totalFollowers, double followerGrowth, long totalPosts,
                                      double avgEngagement, double reachRate, LocalDateTime lastUpdated) {
            this.socialAccountId = socialAccountId;
            this.username = username;
            this.platform = platform;
            this.totalFollowers = totalFollowers;
            this.followerGrowth = followerGrowth;
            this.totalPosts = totalPosts;
            this.avgEngagement = avgEngagement;
            this.reachRate = reachRate;
            this.lastUpdated = lastUpdated;
        }
        
        // Getters and Setters
        public String getSocialAccountId() { return socialAccountId; }
        public void setSocialAccountId(String socialAccountId) { this.socialAccountId = socialAccountId; }
        
        public String getUsername() { return username; }
        public void setUsername(String username) { this.username = username; }
        
        public String getPlatform() { return platform; }
        public void setPlatform(String platform) { this.platform = platform; }
        
        public long getTotalFollowers() { return totalFollowers; }
        public void setTotalFollowers(long totalFollowers) { this.totalFollowers = totalFollowers; }
        
        public double getFollowerGrowth() { return followerGrowth; }
        public void setFollowerGrowth(double followerGrowth) { this.followerGrowth = followerGrowth; }
        
        public long getTotalPosts() { return totalPosts; }
        public void setTotalPosts(long totalPosts) { this.totalPosts = totalPosts; }
        
        public double getAvgEngagement() { return avgEngagement; }
        public void setAvgEngagement(double avgEngagement) { this.avgEngagement = avgEngagement; }
        
        public double getReachRate() { return reachRate; }
        public void setReachRate(double reachRate) { this.reachRate = reachRate; }
        
        public LocalDateTime getLastUpdated() { return lastUpdated; }
        public void setLastUpdated(LocalDateTime lastUpdated) { this.lastUpdated = lastUpdated; }
    }
    
    /**
     * Activity log DTO
     */
    public static class ActivityLogDto {
        @JsonProperty("id")
        private String id;
        
        @JsonProperty("action")
        private String action;
        
        @JsonProperty("description")
        private String description;
        
        @JsonProperty("timestamp")
        private LocalDateTime timestamp;
        
        @JsonProperty("userId")
        private String userId;
        
        @JsonProperty("entityType")
        private String entityType;
        
        @JsonProperty("entityId")
        private String entityId;
        
        public ActivityLogDto() {}
        
        public ActivityLogDto(String id, String action, String description, LocalDateTime timestamp,
                             String userId, String entityType, String entityId) {
            this.id = id;
            this.action = action;
            this.description = description;
            this.timestamp = timestamp;
            this.userId = userId;
            this.entityType = entityType;
            this.entityId = entityId;
        }
        
        // Getters and Setters
        public String getId() { return id; }
        public void setId(String id) { this.id = id; }
        
        public String getAction() { return action; }
        public void setAction(String action) { this.action = action; }
        
        public String getDescription() { return description; }
        public void setDescription(String description) { this.description = description; }
        
        public LocalDateTime getTimestamp() { return timestamp; }
        public void setTimestamp(LocalDateTime timestamp) { this.timestamp = timestamp; }
        
        public String getUserId() { return userId; }
        public void setUserId(String userId) { this.userId = userId; }
        
        public String getEntityType() { return entityType; }
        public void setEntityType(String entityType) { this.entityType = entityType; }
        
        public String getEntityId() { return entityId; }
        public void setEntityId(String entityId) { this.entityId = entityId; }
    }
}
