package kz.konturai.parser.model;

import kz.konturai.parser.dto.StatusHistoryEntry;
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.ArrayList;
import java.util.List;
import java.util.Map;

@Document(collection = "marketing_analysis")
public class MarketingAnalysis {

    @Id
    private String id;

    @Field("business_niche")
    private String businessNiche;

    @Field("product")
    private String product;

    @Field("target_audience")
    private Map<String, Object> targetAudience; // JSON structure: {genders: [], ageRanges: [], types: []}

    @Field("region")
    private List<String> region;

    @Field("goal")
    private String goal;

    @Field("detail_level")
    private String detailLevel; // КРАТКО, СТАНДАРТНО, ПОДРОБНО

    @Field("strong_side")
    private String strongSide;

    @Field("weak_side")
    private String weakSide;

    @Field("analysis_type")
    private List<String> analysisType; // РЫНОК, КОНКУРЕНТЫ, ЦА, КАНАЛЫ, SWOT

    @Field("status")
    private String status; // queued, processing, completed, failed

    @Field("created_at")
    private LocalDateTime createdAt;

    @Field("completed_at")
    private LocalDateTime completedAt;

    @Field("report_data")
    private Map<String, Object> reportData; // JSON data with report content

    @Field("pdf_filename")
    private String pdfFilename;

    @Field("pdf_file_path")
    private String pdfFilePath;

    @Field("user_id")
    private String userId; // Optional, for future authentication

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

    @Field("v2_analysis_id")
    private String v2AnalysisId; // ID связанного v2 анализа

    public MarketingAnalysis() {
        this.createdAt = LocalDateTime.now();
        this.status = "queued";
        this.statusHistory = new ArrayList<>();
    }

    public MarketingAnalysis(String businessNiche, String product, Map<String, Object> targetAudience,
            List<String> region,
            String goal, String detailLevel, String strongSide, String weakSide, List<String> analysisType) {
        this();
        this.businessNiche = businessNiche;
        this.product = product;
        this.targetAudience = targetAudience;
        this.region = region;
        this.goal = goal;
        this.detailLevel = detailLevel;
        this.strongSide = strongSide;
        this.weakSide = weakSide;
        this.analysisType = analysisType;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getProduct() {
        return product;
    }

    public void setProduct(String product) {
        this.product = product;
    }

    public String getBusinessNiche() {
        return businessNiche;
    }

    public void setBusinessNiche(String businessNiche) {
        this.businessNiche = businessNiche;
    }

    public Map<String, Object> getTargetAudience() {
        return targetAudience;
    }

    public void setTargetAudience(Map<String, Object> targetAudience) {
        this.targetAudience = targetAudience;
    }

    public List<String> getRegion() {
        return region;
    }

    public void setRegion(List<String> region) {
        this.region = region;
    }

    public String getGoal() {
        return goal;
    }

    public void setGoal(String goal) {
        this.goal = goal;
    }

    public String getDetailLevel() {
        return detailLevel;
    }

    public void setDetailLevel(String detailLevel) {
        this.detailLevel = detailLevel;
    }

    public String getStrongSide() {
        return strongSide;
    }

    public void setStrongSide(String strongSide) {
        this.strongSide = strongSide;
    }

    public String getWeakSide() {
        return weakSide;
    }

    public void setWeakSide(String weakSide) {
        this.weakSide = weakSide;
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public LocalDateTime getCreatedAt() {
        return createdAt;
    }

    public void setCreatedAt(LocalDateTime createdAt) {
        this.createdAt = createdAt;
    }

    public LocalDateTime getCompletedAt() {
        return completedAt;
    }

    public void setCompletedAt(LocalDateTime completedAt) {
        this.completedAt = completedAt;
    }

    public Map<String, Object> getReportData() {
        return reportData;
    }

    public void setReportData(Map<String, Object> reportData) {
        this.reportData = reportData;
    }

    public String getPdfFilename() {
        return pdfFilename;
    }

    public void setPdfFilename(String pdfFilename) {
        this.pdfFilename = pdfFilename;
    }

    public String getPdfFilePath() {
        return pdfFilePath;
    }

    public void setPdfFilePath(String pdfFilePath) {
        this.pdfFilePath = pdfFilePath;
    }

    public String getUserId() {
        return userId;
    }

    public void setUserId(String userId) {
        this.userId = userId;
    }

    public List<StatusHistoryEntry> getStatusHistory() {
        return statusHistory;
    }

    public void setStatusHistory(List<StatusHistoryEntry> statusHistory) {
        this.statusHistory = statusHistory;
    }

    public List<String> getAnalysisType() {
        return analysisType;
    }

    public void setAnalysisType(List<String> analysisType) {
        this.analysisType = analysisType;
    }

    public String getV2AnalysisId() {
        return v2AnalysisId;
    }

    public void setV2AnalysisId(String v2AnalysisId) {
        this.v2AnalysisId = v2AnalysisId;
    }
}
