using System;
using System.Collections.Generic;

namespace DMS.Core.Models.Triggers
{
    /// <summary>
    /// 触发器动作类型枚举
    /// </summary>
    public enum ActionType
    {
        SendEmail,
        ActivateAlarm,
        WriteToLog,
        // 未来可扩展: ExecuteScript, CallApi, etc.
    }

    /// <summary>
    /// 触发器定义领域模型
    /// </summary>
    public class Trigger
    {
        /// <summary>
        /// 触发器唯一标识符
        /// </summary>
        public int Id { get; set; }

        /// <summary>
        /// 触发器名称
        /// </summary>
        public string Name { get; set; } = "";

        /// <summary>
        /// 关联的变量列表
        /// </summary>
        public List<Variable> Variables { get; set; } = new List<Variable>();

        /// <summary>
        /// 触发器是否处于激活状态
        /// </summary>
        public bool IsActive { get; set; } = true;

        // --- 动作部分 ---

        /// <summary>
        /// 动作类型
        /// </summary>
        public ActionType Action { get; set; }

        /// <summary>
        /// 动作配置 JSON 字符串，存储特定于动作类型的配置（如邮件收件人列表、模板 ID 等）
        /// </summary>
        public string ActionConfigurationJson { get; set; } = "{}";

        // --- 抑制与状态部分 ---

        /// <summary>
        /// 抑制持续时间。如果设置了此值，在触发一次后，在该时间段内不会再触发。
        /// </summary>
        public TimeSpan? SuppressionDuration { get; set; }

        /// <summary>
        /// 上次触发的时间。用于抑制逻辑。
        /// </summary>
        public DateTime? LastTriggeredAt { get; set; }


        /// <summary>
        /// 触发器描述
        /// </summary>
        public string Description { get; set; } = "";

        /// <summary>
        /// 创建时间
        /// </summary>
        public DateTime CreatedAt { get; set; } = DateTime.UtcNow;

        /// <summary>
        /// 最后更新时间
        /// </summary>
        public DateTime UpdatedAt { get; set; } = DateTime.UtcNow;
    }
}