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.ArrayList;
import java.util.List;

@Document(collection = "posting_tasks")
public class PostingTask {

    @Id
    private String id;

    @Field("strategy_id")
    private String strategyId;

    @Field("user_id")
    private String userId;

    @Field("platform")
    private String platform;

    @Field("post_text")
    private String postText;

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

    @Field("publish_date")
    private LocalDateTime publishDate;

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

    @Field("created_at")
    private LocalDateTime createdAt;

    @Field("executed_at")
    private LocalDateTime executedAt;

    @Field("error_message")
    private String errorMessage;

    @Field("image_url")
    private String imageUrl;

    @Field("image_filename")
    private String imageFilename;

    @Field("video_filename")
    private String videoFilename;

    public PostingTask() {
        this.createdAt = LocalDateTime.now();
        this.status = "pending";
        this.hashtags = new ArrayList<>();
    }

    public PostingTask(String strategyId, String userId, String platform, String postText, 
                       List<String> hashtags, LocalDateTime publishDate) {
        this();
        this.strategyId = strategyId;
        this.userId = userId;
        this.platform = platform;
        this.postText = postText;
        this.hashtags = hashtags != null ? hashtags : new ArrayList<>();
        this.publishDate = publishDate;
    }

    public String getId() {
        return id;
    }

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

    public String getStrategyId() {
        return strategyId;
    }

    public void setStrategyId(String strategyId) {
        this.strategyId = strategyId;
    }

    public String getUserId() {
        return userId;
    }

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

    public String getPlatform() {
        return platform;
    }

    public void setPlatform(String platform) {
        this.platform = platform;
    }

    public String getPostText() {
        return postText;
    }

    public void setPostText(String postText) {
        this.postText = postText;
    }

    public List<String> getHashtags() {
        return hashtags;
    }

    public void setHashtags(List<String> hashtags) {
        this.hashtags = hashtags != null ? hashtags : new ArrayList<>();
    }

    public LocalDateTime getPublishDate() {
        return publishDate;
    }

    public void setPublishDate(LocalDateTime publishDate) {
        this.publishDate = publishDate;
    }

    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 getExecutedAt() {
        return executedAt;
    }

    public void setExecutedAt(LocalDateTime executedAt) {
        this.executedAt = executedAt;
    }

    public String getErrorMessage() {
        return errorMessage;
    }

    public void setErrorMessage(String errorMessage) {
        this.errorMessage = errorMessage;
    }

    public String getImageUrl() {
        return imageUrl;
    }

    public void setImageUrl(String imageUrl) {
        this.imageUrl = imageUrl;
    }

    public String getImageFilename() {
        return imageFilename;
    }

    public void setImageFilename(String imageFilename) {
        this.imageFilename = imageFilename;
    }

    public String getVideoFilename() {
        return videoFilename;
    }

    public void setVideoFilename(String videoFilename) {
        this.videoFilename = videoFilename;
    }
}

