using Microsoft.EntityFrameworkCore;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

namespace YBEE.EQM.Core;

/// <summary>
/// 学校班级
/// </summary>
[Comment("学校班级")]
public class SchoolClass : DEntityBase<long>
{
    /// <summary>
    /// 主键：1位学段+4位学校编码+4位入学年份+2位班号
    /// </summary>
    [Comment("主键：1位学段+4位学校ID+4位入学年份+2位班号")]
    [Key, DatabaseGenerated(DatabaseGeneratedOption.None)]
    public override long Id { get; set; }
    /// <summary>
    /// 学校ID
    /// </summary>
    [Comment("学校ID")]
    [Required]
    public short SysOrgId { get; set; }
    /// <summary>
    /// 校区ID
    /// </summary>
    [Comment("校区ID")]
    public short? SysOrgBranchId { get; set; }
    /// <summary>
    /// 学段
    /// </summary>
    [Comment("学段")]
    [Required, Column(TypeName = "smallint")]
    public EducationStage EducationStage { get; set; }
    /// <summary>
    /// 班号
    /// </summary>
    [Comment("班号")]
    [Required]
    public short ClassNumber { get; set; } = 1;
    /// <summary>
    /// 名称：入学年份+级+班号+班，如2025级1班
    /// </summary>
    [Comment("名称：入学年份+级+班号+班，如2025级1班")]
    [Required, StringLength(50)]
    public string Name { get; set; }
    /// <summary>
    /// 全称：学段名+入学年份+级+班号+班，如小学2025级1班
    /// </summary>
    [Comment("全称：学段名+入学年份+级+班号+班，如小学2025级1班")]
    [Required, StringLength(100)]
    public string FullName { get; set; }
    /// <summary>
    /// 简称：班号+班，如1班
    /// </summary>
    [Comment("简称：班号+班，如1班")]
    [Required, StringLength(50)]
    public string ShortName { get; set; }
    /// <summary>
    /// 年份（级）
    /// </summary>
    [Comment("年份（级）")]
    [Required]
    public short GradeBeginYear { get; set; }
    /// <summary>
    /// 年份（届）
    /// </summary>
    [Comment("年级年份")]
    [Required]
    public short GradeEndYear { get; set; }
    /// <summary>
    /// 学制
    /// </summary>
    [Comment("学制")]
    [Required]
    public short EducationYears { get; set; }
    /// <summary>
    /// 备注
    /// </summary>
    [Comment("备注")]
    [StringLength(200)]
    public string Remark { get; set; }
    /// <summary>
    /// 状态
    /// </summary>
    [Comment("状态")]
    [Required, Column(TypeName = "smallint")]
    public CommonStatus Status { get; set; } = CommonStatus.ENABLE;

    /// <summary>
    /// 一对一引用（机构）
    /// </summary>
    public virtual SysOrg SysOrg { get; set; }
    /// <summary>
    /// 一对一引用（校区）
    /// </summary>
    public virtual SysOrg SysOrgBranch { get; set; }
}
