using System;
using System.ComponentModel.DataAnnotations;

namespace DiunaBI.Domain.Entities;

public class QueueJob
{
    public Guid Id { get; set; } = Guid.NewGuid();
    public Guid LayerId { get; set; }
    public string LayerName { get; set; } = string.Empty;
    public string PluginName { get; set; } = string.Empty;
    public JobType JobType { get; set; }
    public int Priority { get; set; } = 0; // 0 = highest priority
    public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
    public int RetryCount { get; set; } = 0;
    public int MaxRetries { get; set; } = 5;
    public JobStatus Status { get; set; } = JobStatus.Pending;
    public string? LastError { get; set; }
    public DateTime? LastAttemptAt { get; set; }
    public DateTime? CompletedAt { get; set; }
    public Guid CreatedById { get; set; }
    public DateTime CreatedAtUtc { get; set; } = DateTime.UtcNow;
    public Guid ModifiedById { get; set; }
    public DateTime ModifiedAtUtc { get; set; } = DateTime.UtcNow;
}

public enum JobType
{
    Import = 0,
    Process = 1
}

public enum JobStatus
{
    Pending,
    Running,
    Completed,
    Failed,
    Retrying
}