using ZelWiki.Library.Interfaces;
namespace ZelWiki.Models.DataModels
{
public class Page : IPage
{
public int Id { get; set; } = 0;
///
/// 正在查看的此页面的修订版。可能不是最新版本
///
public int Revision { get; set; }
///
/// 此页面的最新修订版
///
public int MostCurrentRevision { get; set; }
public bool IsHistoricalVersion => Revision != MostCurrentRevision;
///
/// 此页面是否存在并已加载
///
public bool Exists => Id > 0;
///
/// 修订次数高于修订次数
///
public int HigherRevisionCount { get; set; }
public int DeletedRevisionCount { get; set; }
public string Name { get; set; } = string.Empty;
public string Navigation { get; set; } = string.Empty;
public string Description { get; set; } = string.Empty;
public int DataHash { get; set; }
public string EllipseDescription
{
get
{
var idealLength = 64;
var maxLength = 100;
if (Description.Length > idealLength)
{
int spacePos = Description.IndexOf(' ', idealLength);
int tabPos = Description.IndexOf('\t', idealLength);
idealLength = spacePos > tabPos && tabPos > 0 ? tabPos : spacePos;
if (idealLength > 0 && idealLength < maxLength)
{
return Description.Substring(0, idealLength) + "...";
}
}
if (Description.Length > maxLength)
{
return Description.Substring(0, maxLength) + "...";
}
return Description;
}
}
public Guid CreatedByUserId { get; set; }
public DateTime CreatedDate { get; set; }
public Guid ModifiedByUserId { get; set; }
public DateTime ModifiedDate { get; set; }
public DateTime DeletedDate { get; set; }
public Guid DeletedByUserId { get; set; }
public string DeletedByUserName { get; set; } = string.Empty;
public int TokenWeight { get; set; }
public string Body { get; set; } = string.Empty;
public string CreatedByUserName { get; set; } = string.Empty;
public string ModifiedByUserName { get; set; } = string.Empty;
public int PaginationPageCount { get; set; }
public decimal Match { get; set; }
public decimal Weight { get; set; }
public decimal Score { get; set; }
public string Title
{
get
{
if (Name.Contains("::"))
{
return Name.Substring(Name.IndexOf("::") + 2).Trim();
}
return Name;
}
}
public string Namespace
{
get
{
if (Name.Contains("::"))
{
return Name.Substring(0, Name.IndexOf("::")).Trim();
}
return string.Empty;
}
}
}
}