using Hotline.Orders;
using Hotline.Settings;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Hotline.Users;
using XF.Domain.Repository;

namespace Hotline.KnowledgeBase
{
    [Description("知识审核")]
    [SugarIndex("index_order_creationtime", nameof(KnowledgeApprove.CreationTime), OrderByType.Desc)]
    public class KnowledgeApprove : CreationEntity
    {
        /// <summary>
        /// 知识Id
        /// </summary>
        public string KnowledgeId { get; set; }

        /// <summary>
        /// 审核类型
        /// </summary>
        public EKnowledgeApproveType KnowledgeApproveType { get; set; }

        /// <summary>
        /// 审核状态
        /// </summary>
        public EKnowledgeApproveStatus KnowledgeApproveStatus { get; set; }

        /// <summary>
        /// 审批发起意见
        /// </summary>
        public string? CreateOpinion { get; set; }

        /// <summary>
        /// 审批人Id
        /// </summary>
        public string? ApproverId { get; set; }

        /// <summary>
        /// 审核意见
        /// </summary>
        public string? ApproveOpinion { get; set; }

        /// <summary>
        /// 审核时间
        /// </summary>
        public DateTime? ApproveTime { get; set; }

        [Navigate(NavigateType.OneToOne, nameof(KnowledgeId))]
        public Knowledge Knowledge { get; set; }

        ///// <summary>
        ///// 发起人
        ///// </summary>
        //[Navigate(NavigateType.OneToOne, nameof(CreatorId))]
        //public User Creator { get; set; }

        /// <summary>
        /// 审批人
        /// </summary>
        [Navigate(NavigateType.OneToOne, nameof(ApproverId))]
        public User Approver { get; set; }

        #region method

        public void Approve(string approverId, string approveOpinion, EKnowledgeApproveStatus status)
        {
            ApproverId = approverId;
            ApproveOpinion = approveOpinion;
            KnowledgeApproveStatus = status;
            ApproveTime = DateTime.Now;
        }
        #endregion
    }
}
