using System.ComponentModel.DataAnnotations;

namespace DramaLing.Api.Models.Entities;

public class ImageGenerationRequest
{
    public Guid Id { get; set; }
    public Guid UserId { get; set; }
    public Guid FlashcardId { get; set; }

    // 兩階段狀態追蹤
    [MaxLength(20)]
    public string OverallStatus { get; set; } = "pending"; // pending/description_generating/image_generating/completed/failed

    [MaxLength(20)]
    public string GeminiStatus { get; set; } = "pending";  // pending/processing/completed/failed

    [MaxLength(20)]
    public string ReplicateStatus { get; set; } = "pending"; // pending/processing/completed/failed

    // 請求內容
    [Required]
    public string OriginalRequest { get; set; } = string.Empty;

    public string? GeminiPrompt { get; set; }
    public string? GeneratedDescription { get; set; }
    public string? FinalReplicatePrompt { get; set; }

    // 結果和錯誤
    public Guid? GeneratedImageId { get; set; }
    public string? GeminiErrorMessage { get; set; }
    public string? ReplicateErrorMessage { get; set; }

    // 效能追蹤
    public int? GeminiProcessingTimeMs { get; set; }
    public int? ReplicateProcessingTimeMs { get; set; }
    public int? TotalProcessingTimeMs { get; set; }

    // 成本追蹤
    public decimal? GeminiCost { get; set; }
    public decimal? ReplicateCost { get; set; }
    public decimal? TotalCost { get; set; }

    // 時間戳記
    public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
    public DateTime? GeminiStartedAt { get; set; }
    public DateTime? GeminiCompletedAt { get; set; }
    public DateTime? ReplicateStartedAt { get; set; }
    public DateTime? ReplicateCompletedAt { get; set; }
    public DateTime? CompletedAt { get; set; }

    // Navigation Properties
    public virtual User User { get; set; } = null!;
    public virtual Flashcard Flashcard { get; set; } = null!;
    public virtual ExampleImage? GeneratedImage { get; set; }
}