using Jiaowu.Api.Domain.Common;

namespace Jiaowu.Api.Domain.Academic;

// ═══════════════ 免修 ═══════════════
public sealed class CourseExemption : EntityBase
{
    public Guid StudentId { get; set; }
    public Student? Student { get; set; }
    public Guid TeachingTaskId { get; set; }
    public TeachingTask? TeachingTask { get; set; }
    public required string Reason { get; set; }
    public ApprovalStatus Status { get; set; } = ApprovalStatus.Submitted;
    public string? ReviewComment { get; set; }
    public DateTime SubmittedAt { get; set; } = DateTime.UtcNow;
    public DateTime? ReviewedAt { get; set; }
    public Guid? ReviewedByUserId { get; set; }
}

// ═══════════════ 缓考 ═══════════════
public sealed class DeferredExam : EntityBase
{
    public Guid StudentId { get; set; }
    public Student? Student { get; set; }
    public Guid TeachingTaskId { get; set; }
    public TeachingTask? TeachingTask { get; set; }
    public required string Reason { get; set; }
    public ApprovalStatus Status { get; set; } = ApprovalStatus.Submitted;
    public string? ReviewComment { get; set; }
    public DateTime SubmittedAt { get; set; } = DateTime.UtcNow;
    public DateTime? ReviewedAt { get; set; }
    public Guid? ReviewedByUserId { get; set; }
}

// ═══════════════ 成绩修改（三级审批） ═══════════════
public sealed class GradeModification : EntityBase
{
    public Guid GradeRecordId { get; set; }
    public GradeRecord? GradeRecord { get; set; }
    public decimal CurrentScore { get; set; }
    public decimal RequestedScore { get; set; }
    public required string Reason { get; set; }
    public GradeModificationStatus Status { get; set; } = GradeModificationStatus.TeacherSubmitted;
    public string? ReviewComment { get; set; }
    public Guid ApplicantUserId { get; set; }
    public DateTime SubmittedAt { get; set; } = DateTime.UtcNow;
    public DateTime? CollegeReviewedAt { get; set; }
    public Guid? CollegeReviewedByUserId { get; set; }
    public DateTime? FinalReviewedAt { get; set; }
    public Guid? FinalReviewedByUserId { get; set; }
}

// ═══════════════ 课程替代 ═══════════════
public sealed class CourseSubstitution : EntityBase
{
    public Guid StudentId { get; set; }
    public Student? Student { get; set; }
    public Guid OriginalCourseId { get; set; }
    public Course? OriginalCourse { get; set; }
    public Guid SubstituteCourseId { get; set; }
    public Course? SubstituteCourse { get; set; }
    public required string Reason { get; set; }
    public ApprovalStatus Status { get; set; } = ApprovalStatus.Submitted;
    public string? ReviewComment { get; set; }
    public DateTime SubmittedAt { get; set; } = DateTime.UtcNow;
    public DateTime? ReviewedAt { get; set; }
    public Guid? ReviewedByUserId { get; set; }
}

public enum ApprovalStatus
{
    Submitted = 1,
    Approved = 2,
    Rejected = 3
}

public enum GradeModificationStatus
{
    TeacherSubmitted = 1,
    CollegeApproved = 2,
    Approved = 3,
    Rejected = 4
}
