package kz.konturai.parser.model;

import kz.konturai.parser.dto.StatusHistoryEntry;
import kz.konturai.parser.dto.TargetingAIAnalysisResult;
import kz.konturai.parser.enums.CampaignObjective;
import kz.konturai.parser.enums.TargetingPlatform;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.Document;
import org.springframework.data.mongodb.core.mapping.Field;

import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;

/**
 * Main Targeting Campaign entity.
 */
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Document(collection = "targeting_campaigns")
public class TargetingCampaign {

    @Id
    private String id;

    @Field("user_id")
    private String userId;

    @Field("analysis_id")
    private String analysisId;

    @Field("strategy_id")
    private String strategyId;

    @Field("name")
    private String name;

    @Field("objective")
    private CampaignObjective objective;

    @Field("status")
    private String status; // draft, active, paused, completed, failed

    @Field("platforms")
    private List<TargetingPlatform> platforms;

    @Field("budget")
    private BudgetConfig budget;

    @Field("audience")
    private TargetingAudienceProfile audience;

    @Field("ad_sets")
    private List<TargetingAdSet> adSets;

    @Field("ai_recommendations")
    private TargetingAIAnalysisResult aiRecommendations;

    @Field("insights")
    private List<TargetingInsight> insights;

    @Field("status_history")
    private List<StatusHistoryEntry> statusHistory;

    @Field("performance_metrics")
    private PerformanceMetrics performanceMetrics;

    @Field("ab_test_config")
    private ABTestConfig abTestConfig;

    @Field("external_ids")
    private Map<String, String> externalIds; // platform -> external id

    @Field("created_at")
    private LocalDateTime createdAt;

    @Field("updated_at")
    private LocalDateTime updatedAt;

    @Field("completed_at")
    private LocalDateTime completedAt;

    @Field("duration_days")
    private Integer durationDays;
}
