using Jiaowu.Api.Domain.Common;

namespace Jiaowu.Api.Domain.Academic;

public sealed class WarningRule : EntityBase
{
    public WarningType Type { get; set; }
    public required string Name { get; set; }
    public decimal Threshold { get; set; }
    public bool IsEnabled { get; set; } = true;
    public bool NotifyStudent { get; set; } = true;
    public bool NotifyCounselor { get; set; } = true;
    public Guid AcademicTermId { get; set; }
    public AcademicTerm? AcademicTerm { get; set; }
    public string? Description { get; set; }
    // Auto-check schedule (per-type, independent)
    public bool AutoCheckEnabled { get; set; }
    public int? CheckDayOfWeek { get; set; } // null = daily
    public int CheckHour { get; set; } = 8;
    public int CheckMinute { get; set; }
    public DateTime? LastCheckAt { get; set; }
}

public sealed class WarningRecord : EntityBase
{
    public Guid StudentId { get; set; }
    public Student? Student { get; set; }
    public WarningType Type { get; set; }
    public WarningStatus Status { get; set; } = WarningStatus.Active;
    public decimal TriggerValue { get; set; }
    public required string Detail { get; set; }
    public DateTime? AcknowledgedAt { get; set; }
    public string? AcknowledgeComment { get; set; }
    public Guid AcademicTermId { get; set; }
}

public enum WarningType
{
    FailedCredits = 1,
    LowGPA = 2,
    Absenteeism = 3,
    GraduationDelay = 4
}

public enum WarningStatus
{
    Active = 1,
    Acknowledged = 2,
    Resolved = 3,
    Dismissed = 4
}
