using Jiaowu.Api.Domain.Common;

namespace Jiaowu.Api.Domain.Academic;

public sealed class TeachingTask : EntityBase
{
    public required string TaskNumber { get; set; }
    public required string Name { get; set; }
    public Guid AcademicTermId { get; set; }
    public AcademicTerm? AcademicTerm { get; set; }
    public Guid CourseId { get; set; }
    public Course? Course { get; set; }
    public int Capacity { get; set; }
    public int StartWeek { get; set; } = 1;
    public int EndWeek { get; set; } = 16;
    public int WeeklyHours { get; set; } = 2;
    public TeachingTaskSchedulingMode SchedulingMode { get; set; } =
        TeachingTaskSchedulingMode.Standard;
    public TeachingTaskStatus Status { get; set; } = TeachingTaskStatus.Draft;
    public string? GenerationBatchCode { get; set; }
    public string? Notes { get; set; }
    public DateTime? PublishedAt { get; set; }
    public ICollection<TeachingTaskTeacher> Teachers { get; set; } = [];
    public ICollection<TeachingTaskClass> Classes { get; set; } = [];
}

public sealed class TeacherCourseApplication : EntityBase
{
    public Guid AcademicTermId { get; set; }
    public AcademicTerm? AcademicTerm { get; set; }
    public Guid TeacherId { get; set; }
    public Teacher? Teacher { get; set; }
    public Guid CourseId { get; set; }
    public Course? Course { get; set; }
    public TeacherCourseApplicationStatus Status { get; set; } =
        TeacherCourseApplicationStatus.Pending;
    public string? Statement { get; set; }
    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 TeachingTaskTeacher
{
    public Guid TeachingTaskId { get; set; }
    public TeachingTask? TeachingTask { get; set; }
    public Guid TeacherId { get; set; }
    public Teacher? Teacher { get; set; }
    public bool IsPrimary { get; set; }
}

public sealed class TeachingTaskClass
{
    public Guid TeachingTaskId { get; set; }
    public TeachingTask? TeachingTask { get; set; }
    public Guid AdministrativeClassId { get; set; }
    public AdministrativeClass? AdministrativeClass { get; set; }
}

public enum TeachingTaskStatus
{
    Draft = 1,
    Published = 2,
    Closed = 3
}

public enum TeachingTaskSchedulingMode
{
    Standard = 1,
    Flexible = 2
}

public enum TeacherCourseApplicationStatus
{
    Pending = 1,
    Approved = 2,
    Rejected = 3,
    Withdrawn = 4
}
