From 61b72ca3499bbffc16fe5adf5cacd056e19e9134 Mon Sep 17 00:00:00 2001 From: "DESKTOP-M4V1LH5\\Jin" Date: Tue, 8 Jan 2019 22:04:12 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=96=87=E7=AB=A0=E6=96=B9?= =?UTF-8?q?=E6=B3=95=EF=BC=8C=E4=B8=8A=E4=B8=8B=E7=AF=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- COMCMS.Core/Article/文章.Biz.cs | 59 +++++++++++++++++++++++++ COMCMS.Core/Article/文章栏目.Biz.cs | 29 ++++++++++++ 2 files changed, 88 insertions(+) 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