using System;
using System.ComponentModel.DataAnnotations;
using Abp.Domain.Entities;
using Abp.Domain.Entities.Auditing;
using Mapster;
using YGNT.QuestionLibrary.Core.Models;

namespace YGNT.QuestionLibrary.Core.Questions
{
    /// <summary>
    /// 试题解析内容
    /// </summary>
    public class Resolve : Entity<long>, IModificationAudited, ISoftDelete, IHasCreationTime
    {
        private DateTime? _lastModificationTime;

        /// <summary>
        /// 原始试题数据id
        /// </summary>
        [Required]
        public long QuestionOriginId { get; set; }

        /// <summary>
        /// html文本
        /// </summary>
        public string Html { get; set; }

        /// <summary>
        /// 排序
        /// </summary>
        public int Sort { get; set; }

        /// <summary>
        /// 文档文件路径(相对路径)
        /// </summary>
        public string XmlPath { get; set; }

        /// <summary>
        /// 解析内容的类型
        /// </summary>
        public ResolveType ResolveType { get; set; }

        /// <summary>
        /// 是否是答案
        /// </summary>
        public bool IsAnswer { get; set; }

        /// <summary>
        /// 试题原数据
        /// </summary>
        [AdaptIgnore]
        public QuestionOrigin QuestionOrigin { get; set; }

        /// <summary>
        /// 是否已被修改
        /// </summary>
        public bool IsModified { get; set; }

        public DateTime CreationTime { get; set; }

        public DateTime? LastModificationTime
        {
            get => _lastModificationTime;
            set
            {
                IsModified = true;
                _lastModificationTime = value;
            }
        }

        public long? LastModifierUserId { get; set; }

        public bool IsDeleted { get; set; }
    }
}