package kz.konturai.parser.model;

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.Map;

@Document(collection = "market_items")
public class MarketItem {

    @Id
    private String id;

    @Field("source_name")
    private String sourceName;

    @Field("url")
    private String url;

    @Field("title")
    private String title;

    @Field("published_at")
    private LocalDateTime publishedAt;

    @Field("added_at")
    private LocalDateTime addedAt;

    @Field("raw_text")
    private String rawText;

    @Field("hash")
    private String hash;

    @Field("category")
    private String category;

    @Field("analytics")
    private Analytics analytics;

    // Конструкторы
    public MarketItem() {
        this.addedAt = LocalDateTime.now();
        this.sourceName = "Kursiv (Бизнес/экономика)";
        this.category = "Бизнес";
        this.analytics = new Analytics();
    }

    public MarketItem(String url, String title, LocalDateTime publishedAt, String rawText, String hash) {
        this();
        this.url = url;
        this.title = title;
        this.publishedAt = publishedAt;
        this.rawText = rawText;
        this.hash = hash;
    }

    // Getters and Setters
    public String getId() {
        return id;
    }

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

    public String getSourceName() {
        return sourceName;
    }

    public void setSourceName(String sourceName) {
        this.sourceName = sourceName;
    }

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public LocalDateTime getPublishedAt() {
        return publishedAt;
    }

    public void setPublishedAt(LocalDateTime publishedAt) {
        this.publishedAt = publishedAt;
    }

    public LocalDateTime getAddedAt() {
        return addedAt;
    }

    public void setAddedAt(LocalDateTime addedAt) {
        this.addedAt = addedAt;
    }

    public String getRawText() {
        return rawText;
    }

    public void setRawText(String rawText) {
        this.rawText = rawText;
    }

    public String getHash() {
        return hash;
    }

    public void setHash(String hash) {
        this.hash = hash;
    }

    public String getCategory() {
        return category;
    }

    public void setCategory(String category) {
        this.category = category;
    }

    public Analytics getAnalytics() {
        return analytics;
    }

    public void setAnalytics(Analytics analytics) {
        this.analytics = analytics;
    }

    // Вложенный класс для аналитики
    public static class Analytics {
        private String summary;
        private String sentiment;
        private String[] tags = {};
        private Map<String, Object> entities = Map.of();

        public Analytics() {
        }

        public String getSummary() {
            return summary;
        }

        public void setSummary(String summary) {
            this.summary = summary;
        }

        public String getSentiment() {
            return sentiment;
        }

        public void setSentiment(String sentiment) {
            this.sentiment = sentiment;
        }

        public String[] getTags() {
            return tags;
        }

        public void setTags(String[] tags) {
            this.tags = tags;
        }

        public Map<String, Object> getEntities() {
            return entities;
        }

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