using Hotline.Settings;
using Hotline.Users;
using SqlSugar;
using System.ComponentModel;
using XF.Domain.Repository;
using Hotline.Share.Enums.Caselibrary;
using Hotline.Share.Dtos.File;
using Hotline.Orders;
using Hotline.KnowledgeBase;

namespace Hotline.CaseLibrary;

/// <summary>
/// 案例库列表内容
/// </summary>
[Description("案例库列表")]

[SugarIndex("index_caselibrary_creatorOrgId", nameof(CaseList.CreatorOrgId), OrderByType.Desc)]
public class CaseList : CreationEntity
{
    /// <summary>
    /// 标题
    /// </summary>
    [SugarColumn(ColumnDescription = "标题")]
    public string Title { get; set; }

    /// <summary>
    /// 摘要
    /// </summary>
    [SugarColumn(ColumnDescription = "摘要")]
    public string? Abstract { get; set; }

    /// <summary>
    /// 关键词
    /// </summary>
    //[SugarColumn(ColumnDataType = "json", IsJson = true, IsNullable = true, ColumnDescription = "关键词")]
    //public List<string>? Keywords { get; set; }

    [SugarColumn(ColumnDescription = "关键词")]
    public string? Keywords { get; set; }

    /// <summary>
    /// 案例描述
    /// </summary>
    [SugarColumn(ColumnDescription = "案例描述")]
    public string Describe { get; set; }

    /// <summary>
    /// 案例结果
    /// </summary>
    [SugarColumn(ColumnDescription = "案例结果")]
    public string Result { get; set; }

    /// <summary>
    /// 推荐理由
    /// </summary>
    [SugarColumn(ColumnDescription = "推荐理由")]
    public string Reason { get; set; }

    /// <summary>
    /// 是否热门
    /// </summary>
    [SugarColumn(ColumnDescription = "是否热门")]
    public bool? IsPopular { get; set; } = false;

    /// <summary>
    /// 案例申请状态
    /// </summary>
    [SugarColumn(ColumnDescription = "案例申请状态")]
    public ECaseApplyStatus ApplyStatus { get; set; }

    /// <summary>
    /// 案例状态
    /// </summary>
    [SugarColumn(ColumnDescription = "案例状态")]
    public ECaseStatus Status { get; set; }

    /// <summary>
    /// 是否删除
    /// </summary>
    [SugarColumn(ColumnDescription = "是否删除")]
    public bool? IsDeleted { get; set; } = false;

    /// <summary>
    /// 阅读次数
    /// </summary>
    [SugarColumn(ColumnDescription = "阅读次数")]
    public int PageView { get; set; } = 0;

    /// <summary>
    /// 上架时间
    /// </summary>
    [SugarColumn(ColumnDescription = "上架时间")]
    public DateTime? OnShelfTime { get; set; }

    /// <summary>
    /// 下架时间
    /// </summary>
    [SugarColumn(ColumnDescription = "下架时间")]
    public DateTime? OffShelfTime { get; set; }

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

    /// <summary>
    /// 创建部门
    /// </summary>
    [Navigate(NavigateType.OneToOne, nameof(CreatorOrgId))]//一对一 
    public SystemOrganize? SystemOrganize { get; set; }

    /// <summary>
    /// 更新时间
    /// </summary>
    [SugarColumn(ColumnDescription = "更新时间")]
    public DateTime? UpdateTime { get; set; }

    /// <summary>
    /// 申请理由
    /// </summary>
    [SugarColumn(ColumnDescription = "申请理由")]
    public string? ApplyReason { get; set; }

    /// <summary>
    /// 审核意见
    /// </summary>
    [SugarColumn(ColumnDescription = "审核意见")]
    public string? ExaminOpinion { get; set; }

    /// <summary>
    /// 审核人ID
    /// </summary>
    public string? ExaminManId { get; set; }

    /// <summary>
    /// 审核人
    /// </summary>
    [Navigate(NavigateType.OneToOne, nameof(ExaminManId))]
    public User? ExaminMan { get; set; }

    /// <summary>
    /// 审核部门ID
    /// </summary>
    [SugarColumn(ColumnDescription = "审核部门")]
    public string? ExaminOrganizeId { get; set; }

    /// <summary>
    /// 审核部门
    /// </summary>
    [Navigate(NavigateType.OneToOne, nameof(ExaminOrganizeId))]//一对一 
    public SystemOrganize? ExaminOrganize { get; set; }

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

    /// <summary>
    /// 失效时间
    /// </summary>
    [SugarColumn(ColumnDescription = "失效时间")]
    public DateTime? ExpiredTime { get; set; }

    /// <summary>
    /// 评分
    /// </summary>
    [SugarColumn(ColumnDescription = "评分")]
    public decimal? Score { get; set; } = decimal.Zero;

    /// <summary>
    /// 工单ID
    /// </summary>
    public string OrderId { get; set; }

    /// <summary>
    /// 工单
    /// </summary>
    [Navigate(NavigateType.OneToOne, nameof(OrderId))]
    public Order Order { get; set; }

    /// <summary>
    /// 知识库ID
    /// </summary>
    public string? KnowledgeId { get; set; }

    /// <summary>
    /// 知识库
    /// </summary>
    [Navigate(NavigateType.OneToOne, nameof(KnowledgeId))]
    public Knowledge? Knowledge { get; set; }

    /// <summary>
    /// 案例库类型关联ID
    /// </summary>
    //[Navigate(NavigateType.OneToMany, nameof(CaseRelationType.CaseId))]
    //   public List<CaseRelationType> CaseTypes { get; set; }

    [Navigate(typeof(CaseRelationType), nameof(CaseRelationType.CaseId), nameof(CaseRelationType.CaseTypeId))]
    public List<CaseType> CaseTypes { get; set; }

    /// <summary>
    /// 附件
    /// </summary>
    [SugarColumn(ColumnDataType = "json", IsJson = true, IsNullable = true)]
    public List<FileJson>? FileJson { get; set; }
}