using Health.Domain.Enums;
using System.ComponentModel.DataAnnotations.Schema;

namespace Health.Domain.Entities;

/// <summary>
/// AI 对话会话
/// </summary>
public sealed class Conversation
{
    public Guid Id { get; set; }
    public Guid UserId { get; set; }
    public AgentType AgentType { get; set; }
    public string? Title { get; set; }
    public string? Summary { get; set; }          // 侧滑抽屉显示用摘要
    public int MessageCount { get; set; }
    public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
    public DateTime UpdatedAt { get; set; } = DateTime.UtcNow;

    public User User { get; set; } = null!;
    public ICollection<ConversationMessage> Messages { get; set; } = [];
}

/// <summary>
/// AI 对话消息
/// </summary>
public sealed class ConversationMessage
{
    public Guid Id { get; set; }
    public Guid ConversationId { get; set; }
    public MessageRole Role { get; set; }
    public string Content { get; set; } = string.Empty;
    public string? Intent { get; set; }           // health_record / diet / medication / exercise / report / chat
    [Column(TypeName = "jsonb")]
    public string? MetadataJson { get; set; }    // 结构化数据（录入数值、食物列表、卡片数据等）
    public DateTime CreatedAt { get; set; } = DateTime.UtcNow;

    public Conversation Conversation { get; set; } = null!;
}
