using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Abp.Domain.Entities;
using YGNT.QuestionLibrary.Core.Disciplines;
using YGNT.QuestionLibrary.Core.Textbooks;

namespace YGNT.QuestionLibrary.Core.Chapters
{
    /// <summary>
    /// 章节
    /// </summary>
    public class Chapter : Entity<long>, ISoftDelete
    {
        /// <summary>
        /// 章节名称
        /// </summary>
        [Required]
        public string Name { get; set; }

        /// <summary>
        /// 教材id
        /// </summary>
        [Required]
        public int TextbookId { get; set; }

        /// <summary>
        /// 所属学科id
        /// </summary>
        [Required]
        public int DisciplineId { get; set; }

        /// <summary>
        /// 父章节Id
        /// </summary>
        public long? ParentId { get; set; }

        /// <summary>
        /// 排序
        /// </summary>
        [Required]
        [DefaultValue(0)]
        public int Sort { get; set; }

        /// <summary>
        /// 备注
        /// </summary>
        public string Remark { get; set; }

        /// <summary>
        /// 父章节
        /// </summary>
        [ForeignKey(nameof(ParentId))]
        public Chapter ParentChapter { get; set; }

        /// <summary>
        /// 子章节
        /// </summary>
        public List<Chapter> ChildChapters { get; set; }

        /// <summary>
        /// 所属学科
        /// </summary>
        [ForeignKey(nameof(DisciplineId))]
        [Required]
        public Discipline Discipline { get; set; }

        /// <summary>
        /// 教材
        /// </summary>
        [ForeignKey(nameof(TextbookId))]
        public Textbook Textbook { get; set; }

        public bool IsDeleted { get; set; }
    }
}