diff --git a/COMCMS.Core/Article/文章.Biz.cs b/COMCMS.Core/Article/文章.Biz.cs index 0b3e65a..ab9ff46 100644 --- a/COMCMS.Core/Article/文章.Biz.cs +++ b/COMCMS.Core/Article/文章.Biz.cs @@ -153,6 +153,65 @@ namespace COMCMS.Core #endregion #region 业务操作 + /// + /// 获取上一条记录/前一条记录 + /// + /// ID + /// + public static Article GetPrev(int id) + { + Article entity = Article.FindById(id); + if (entity != null) + { + //获取上一条记录 + IList
list = Article.FindAll(_.Id > entity.Id & _.KId == entity.KId & _.Sequence <= entity.Sequence, string.Format("{0} Desc,{1} Asc", _.Sequence, _.Id), null, 0, 1); + if (list != null && list.Count > 0) + return list[0]; + else + { + list = Article.FindAll(_.Id != entity.Id & _.KId == entity.KId & _.Sequence < entity.Sequence, string.Format("{0} Desc,{1} Asc", _.Sequence, _.Id), null, 0, 1); + if (list != null && list.Count > 0) + { + return list[0]; + } + else + return null; + } + + } + else + return null; + } + + /// + /// 获取下一条记录/后一条记录 + /// + /// + /// + public static Article GetNext(int id) + { + Article entity = Article.FindById(id); + if (entity != null) + { + //获取上一条记录 + IList
list = Article.FindAll(_.Id != entity.Id & _.KId == entity.KId & _.Sequence > entity.Sequence, string.Format("{0} Asc,{1} Desc", _.Sequence, _.Id), null, 0, 1); + if (list != null && list.Count > 0) + return list[0]; + else + { + list = Article.FindAll(_.Id < entity.Id & _.KId == entity.KId & _.Sequence >= entity.Sequence, string.Format("{0} Asc,{1} Desc", _.Sequence, _.Id), null, 0, 1); + if (list != null && list.Count > 0) + { + return list[0]; + } + else + return null; + } + + } + else + return null; + } #endregion } } \ No newline at end of file diff --git a/COMCMS.Core/Article/文章栏目.Biz.cs b/COMCMS.Core/Article/文章栏目.Biz.cs index e82eafa..ac2d0f5 100644 --- a/COMCMS.Core/Article/文章栏目.Biz.cs +++ b/COMCMS.Core/Article/文章栏目.Biz.cs @@ -325,6 +325,35 @@ namespace COMCMS.Core } } } + + /// + /// 获取当前位置 + /// + /// 类别ID + /// + public static string GetNav(int kid) + { + string tpl = "{1}"; + string re = string.Empty; + ArticleCategory model = Find(_.Id == kid); + if (model == null) + { + re = string.Format(tpl, "/", "首页") + re;//查到最后肯定是没有 + } + else + { + re += " > " + string.Format(tpl, "/article/index/" + model.Id, model.KindName); + if (model.PId != 0) + { + re = GetNav(model.PId) + re; + } + else + { + re = string.Format(tpl, "/", "首页") + re;//查到最后肯定是没有 + } + } + return re; + } #endregion } } \ No newline at end of file